Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Metlab code

Status
Not open for further replies.

alexander156

Student
Oct 24, 2020
1

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:
 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]
 
Replies continue below

Recommended for you

[highlight #EF2929]Student forum QC expert system v0.12 alpha

Recommendation - Need to improve question.

Please provide a better explanation of what you are trying to achieve.
Debug 68504913[/highlight]


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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor