Error in find command....
Afficher commentaires plus anciens
t=linspace(xq(1),xq(np),1001)
y2=polyval(pmon,t)
plot(t,y2,'k--',x)
for j=1:6
for i=1:1001;
t1(j)=find(y2(i)=pmon(j))
end
end
i want to find value of t(x axis) for which value of pmon(y axis) is given ??
Réponses (1)
Adam Danz
le 14 Mar 2019
One equal sign assigns a value to a variable.
Two equal signs perfoms a comparison between A and B and returns a logical value.
t1(j) = find(y2(i) = pmon(j)) %incorrect
t1(j) = find(y2(i) == pmon(j)) %correct
12 commentaires
shoaib Ch
le 14 Mar 2019
madhan ravi
le 14 Mar 2019
Remember you are dealing with float numbers so add tolerance.
Adam Danz
le 14 Mar 2019
Please provide the full copy-pasted error message and relevant code that produces the error.
shoaib Ch
le 14 Mar 2019
Adam Danz
le 14 Mar 2019
There must be a mistake with the code you provided.
1) the first line causes an error because the vector is not enclosed in [brackets].
2) the loop k=1:pos_a, pos_a is a vector, not an integer.
Adam Danz
le 14 Mar 2019
if pos_a(k)>= pos_a(k)+1
How would this ever be true?
shoaib Ch
le 15 Mar 2019
Adam Danz
le 15 Mar 2019
I understand how the 'if' command works. What I don't understand is what you're trying to do with it. Your statement
if pos_a(k)>= pos_a(k)+1
is analogous to
if x >= x+1
which would never be the case.
Did you mean to this?
if pos_a(k)>= pos_a(k+1)
Sorry, I don't understand your last question above.
shoaib Ch
le 15 Mar 2019
Adam Danz
le 15 Mar 2019
Please provide a minimal working example so I can reproduce your problem.
shoaib Ch
le 15 Mar 2019
shoaib Ch
le 15 Mar 2019
Catégories
En savoir plus sur Medical Physics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

