Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - MATLAB input a function, such as y=x? , how to assign a value to y and find X.
MATLAB input a function, such as y=x? , how to assign a value to y and find X.
According to the following steps, you can realize the function of assigning value to y and finding x.

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)