Hi!
I would like you to help me with the MetLab code below. I do not know where I am wrong. Can a member help me?
CODE --> -8
xl=1 xu=2 x1=-4:0.01:4; y=polyval(p1,x1); plot(x1,y1) grid xlabel('oi times tou x') ylabel ('oi times tou y') for i=1:16 mesi=(xu+xl)/2; timixu=polyval (p1,xu); timixl=polyval (p1,xl); timimesi=polyval(p1,mesi); if timimesi*timixu<0 xl=mesi result=mesi; else xu=mesi result=mesi; end end
p2=[-1 2,71^1 -4] xl=1 xu=2 sfalma=1 i=0 resultold=2 x2=-4:0,01:4; y2=polyval(p2,x2); plot(x2,y2) grid xlabel('oi times tou x') ylabel ('oi times tou y') while sfalma>0,00001 mesi=(xu+xl)/2 timixu=polyval (p2,xu) timixl=polyval (p2,xl) timimesi=polyval (p2,mesi) if (timimesi*timixu<0) xl=mesi else xu=mesi end result=mesi; sfalma=abs((result-resultold)/result*100) result=resultold i=i+1 end]
RE: Problem with Metlab code
Recommendation - Need to improve question.
Please provide a better explanation of what you are trying to achieve.
Debug 68504913
You write uncommented code. So do I occassionally but expect no sympathy when it comes to debugging
Also please format it correctly
You have at least one syntax error and one variable that has not been initialised
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?