I have a function which depends on 2 variables. I would like to write a script in which I input the value of one of the variables, and then MATLAB solves for the other variable. However, the function is non-linear so I believe using the fsolve command would be the best. This is the script that I have written so far:
r = input('Range of the target')
fun = @BallRange;
angle = fsolve(fun,60)
function R = BallRange(r,x)
R = r*sin(2*x) + 0.7*(cos(x)^2) - 0.176275*r^2
However, I get multiple error codes when I try to run the program.
How can I change the code so I can get the desired output (angle)?
Furthermore, would it be possible to make an algorithm to plot a function with r on the x-axis ranging from 2 to 6 with increments of 0.1 and the corresponding angle on the y-axis?
Thank you in advance,