MATLAB Answers

invalid use of operator

5 views (last 30 days)
mohammad massarwe
mohammad massarwe on 3 May 2021
Commented: James Tursa on 3 May 2021
>>shitathatsia = @(x) 2.7*cos(25*x^2+8*x)-10*x*sin(6*x)
starrt=-1
ennd=1
pitaron= (starrt+ennd)/2
while sqrt((shitathatsia(pitaron))^2)> 0.001
if(shitathatsia(pitaron)) * shitathatsia(start) <0
starrt = pitaron
if shitathatsia(pitaron)) * shitathatsia(start) >0
ennd=pitaron
end
pitaron=(starrt+ennd)/2
end
fprintf(pitaron)

Answers (1)

James Tursa
James Tursa on 3 May 2021
You are missing a ( after the second "if", and you are missing an "end" statement. That being said, my suggestion would be to use an "else" instead as that appears to be your intent. E.g.,
if ( condition )
starrt = pitaron;
else
ennd = pitaron;
end
  8 Comments
James Tursa
James Tursa on 3 May 2021
Get rid of the >> as Walter suggests.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!