[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Thu, 12 Aug 2010 03:23:13 -0700 (PDT)
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
%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;
%This bit is to remove the false crossing points, peaks are typically 30
for j = 1:1:length(cross)
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;
%removing zeros from cross
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
%and calculates if between two crossing points there is a maximum (the if
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
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.
Pretty much convinced Octave>Excel for scientific data analysis!
View this message in context:
Sent from the Octave - General mailing list archive at Nabble.com.
Re: Parse error?, Olaf Till, 2010/08/12