Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

Can someone please teach me on how to create a script in Scilab that would evaluate for an intersection on point of two given functions and plot the functions. Thank you :)

OpenStudy (anonymous):

oh :(

OpenStudy (anonymous):

well.. it seems there is a function `fsolve()` for that. I played with it a little and got this: ``` deff('res=f1(x)','res=3*x') deff('res=f2(x)','res=sin(x)+3') deff('res=fsol(x)','res=f2(x)-f1(x)') x0 = 0. xsol =fsolve(x0,fsol) edge = 4 x = linspace(-edge,edge,51) scf(1) clf(1) plot(x,f1,'r-'); p = get("hdl"); p.children.thickness = 3; plot(x,f2,'b-'); p = get("hdl"); p.children.thickness = 3; xgrid(1, 1, 7) ``` at the end `xsol` should have the x-value of the intersection. For that code I got the attached graph and `xsol=1.32` which makes sense: http://www.wolframalpha.com/input/?i=sin%28x%29+%2B+3+%3D+3x I did some more reading here: http://www.openeering.com/sites/default/files/Nonlinear_Systems_Scilab.pdf It says that `fsolve()` is based on Newton's method to find the 0 of the given function. That means that it's not a magic function that can solve anything.. you have to take into consideration whether it can solve `fsol(x)` using the given `x0` or not. Anyway, I hope it helps =)

OpenStudy (anonymous):

@pitamar and @DavidUsa thank you :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!