help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parse error?


From: dirac
Subject: Parse error?
Date: Thu, 12 Aug 2010 03:23:13 -0700 (PDT)

Hi everyone,

This is a bit of a long winded question: I am having problems with my code.
I can't seem to get by it. Basically I am wanting to read in a file, do some
analysis on it and then have a plot output.

The piece of code below first reads in the file, splits the file into
vectors and then the analysis. The function aver calculates the running mean
of the data which, has many peaks. The idea is to find the points in the
data set that just cross the running mean. I then want to fit a curve to the
peak and find the maximum. This is essentially a peak finiding program.


function gn = groupindcnt(filename);


f = dlmread(filename);
lambda = f(2:end,1);
power = f(2:end,2:21);
runmean = aver(lambda, power);

%This for loop will loop over all the currents/columns in power
for crnt = 1:1:20
  data = power(:,crnt);
  sign = 1;
  cross = zeros(1000,1);
  n = 1;
  

  %This bit is finding the data points just above and below the running
mean.
  %and places a 1 in the vector cross.
  for i = 1:1:9000
    if (sign*(data(i+499)-runmean(i,crnt)) > 0)
        sign = -1*sign;
    cross(i) = 1;
    n = n + 1;
    end
  end
  
  %This bit is to remove the false crossing points, peaks are typically 30
data
  %points wide.
  for j = 1:1:length(cross)
    if (cross(j)==1)
      cross(j+1) = 0;
          cross(j+2) = 0;
          cross(j+3) = 0;
          cross(j+4) = 0;
          cross(j+5) = 0;
          cross(j+6) = 0;
          cross(j) = j;
    end
  end
  
  %removing zeros from cross 
  cross(cross==0)=[];
  data_cp = data(cross+499,:);
  lambda_cp = lambda(cross+499);
  


  %This is the bit I am having problems with, it runs through all of the
crossing points
  %and calculates if between two crossing points there is a maximum (the if
statement).
  for k = 2:1:length(cross)-1
    cp = (499+ cross(k) + round((cross(k+1) - cross(k))/2));
        ll = data((499 + cross(k)));
        hl = data((499 + cross(k+1)));
        ml = data(cp);
        
        if (ml > ((hl+ll)/2)

               %ANYTHING ADDED IN HERE RETURNS PARSE ERROR
               %This is where I want to do the curve fitting
      
            end
        
        
        
  end  
end
end



This may be a bit hard to understand; it is dificult reading other peoples
code I know!

Basically anything I put in the IF statement causes a 'parse' error.

Any suggestions?

Cheers
Martin

-----
Pretty much convinced Octave>Excel for scientific data analysis!
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Parse-error-tp2322504p2322504.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]