help-octave
[Top][All Lists]
Advanced

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

strcmp not functioning as expected


From: CanadaPhil
Subject: strcmp not functioning as expected
Date: Sat, 12 Mar 2011 09:00:06 -0800 (PST)

Hello,
I am using the following code to query the first column of a cell array for
unique values and add them to a new cell array.  I am using strcmp to
determine if the last unique string is the same as the first entry on the
currect row.  The code does not run properly though because the return of
strcmp is a matrix (clearly not what I want).  How can I correct my problem
with strcmp?  
Thanks,
Phil


function Indicators()
Indi={"EMA","Buy on Price Cross","EMA Period","-","-","-","-","-";
"EMA","Sell on Price Cross","EMA Period","-","-","-","-","-";
"MACD","Buy on EMA Cross","Fast EMA Period","Slow EMA
Period","-","-","-","-";
"MACD","Sell on EMA Cross","Fast EMA Period","Slow EMA
Period","-","-","-","-";};

AvailIndi={Indi{1,1}}
LastIndi=Indi{1,1}
IndiLine=2
AvailIndiLine=2

while (IndiLine<=rows(Indi))
disp("Indi{IndiLine,1}=");
disp(Indi{IndiLine,1});
disp("LastIndi=");
disp(LastIndi);
disp("strcmp(Indi{IndiLine,1},LastIndi)=");
disp(strcmp(Indi{IndiLine,1},LastIndi));
  if (strcmp(Indi{IndiLine,1},LastIndi)=1)
    printf ("same as previous\n");
  else
    printf ("different than previous\n");
    AvailIndi{AvailIndiLine,1}=Indi{IndiLine,1}
    LastIndi=Indi{IndiLine,1}
    AvailIndiLine=AvailIndiLine+1
  endif
  IndiLine=IndiLine+1;
endwhile
printf(AvailIndi);

--
View this message in context: 
http://octave.1599824.n4.nabble.com/strcmp-not-functioning-as-expected-tp3350509p3350509.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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