question on citing the output message of fzero function.

hi all,I have one question about fzero. Below is my sample code, where I try to set the result delta(j)=NaN if the output.message is 'Zero find terminated.'. To do this, I use strcmp, but it doesn't work because it does recognize the variable 'output.message'. what is the right way to cite the message? This annoys me a lot...
for j=1:length_gamma
[dlt fval eflag output]=fzero(@(delt) vdiff(data,gamma(j),delt),[0 1]);
delta(j)=dlt;
if strcmp('output.message','Zero find terminated.')==1
delta(j)=NaN;
end
end

Réponses (2)

Guang
Guang le 6 Mai 2011

1 vote

I got it.
use strcmp(output.message,'Zero find terminated.')==1 instead of strcmp('output.message','Zero find terminated.')==1
Sean de Wolski
Sean de Wolski le 6 Mai 2011

0 votes

One thing to test: use strcmpi so that it's not case sensitive.

2 commentaires

Sean de, thanks, but it doesn't work.
My key question would be how to cite the message of the output. Is 'output.message'
a correct way to do so?
try output.message without the quotation marks.

Connectez-vous pour commenter.

Catégories

Question posée :

le 6 Mai 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by