1. Create a custom function file and save it in the current file directory with the file name myfun.m
Function x= myfun(y)
x = sqrt(y);
end
2. In the current file directory, enter in the command window.
& gt& gty = 10; x=myfun(y)
x = 3. 1623
& gt& gty = 16; x=myfun(y)
x = 4
Ask close questions
What if we use submarines?
And this y is still an independent variable. What I want to ask is the dependent variable.
One answer after another.
Yes, change the custom function to
Function x= myfun(y)
Symbol x
x=solve(y-x^2);
end
& gt& gty = 8; x= myfun(y)
x =
-2*2^( 1/2)
2*2^( 1/2)
& gt& gty = 10; x= myfun(y)
x =
10^( 1/2)
- 10^( 1/2)