Error in find command....
Ältere Kommentare anzeigen
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 ??
Antworten (1)
Adam Danz
am 14 Mär. 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 Kommentare
shoaib Ch
am 14 Mär. 2019
madhan ravi
am 14 Mär. 2019
Remember you are dealing with float numbers so add tolerance.
Adam Danz
am 14 Mär. 2019
Please provide the full copy-pasted error message and relevant code that produces the error.
shoaib Ch
am 14 Mär. 2019
Adam Danz
am 14 Mär. 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
am 14 Mär. 2019
if pos_a(k)>= pos_a(k)+1
How would this ever be true?
shoaib Ch
am 15 Mär. 2019
Adam Danz
am 15 Mär. 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
am 15 Mär. 2019
Adam Danz
am 15 Mär. 2019
Please provide a minimal working example so I can reproduce your problem.
shoaib Ch
am 15 Mär. 2019
shoaib Ch
am 15 Mär. 2019
Kategorien
Mehr zu Medical Physics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

