I would like to have a function, namely fsolve, and what you must put into the command window to output an answer into one .m file, so everything is inside the .m file, and I do not have to type anything into the command window. I need to have only one .m file as well. Is this possible or must I type things into the command window. I understand that to solve a system of nonlinear equations using fsolve, we must type things into the command window, but is it possible to have these things inside the same .m file as the root2d.m file and to have the program run without anything typed into the command window? I understand this may be not a smart question to ask, but I have not use MATLAB in several months and I am working on an assignment for a professor.
The fsolve and root2d.m file that I am referring to are referenced on this page on the first example
https://www.mathworks.com/help/optim/ug/fsolve.html
Here is my code
function F = root2d(x)F(1) = 1/sqrt(x(1)) + 2*log10((2.51*0.00001655)/(x(2)*0.267*sqrt(x(1))))F(2) = 20 - x(1)*(300/0.267)*((x(2))^2/(2*9.81))endfun = @root2d;x0 = [0,0];x = fsolve(fun,x0)
Best Answer