Function Handle Not Reading the Input I want Evaluated
Show older comments
Here is my code, I am having an issue with the function handle not reading the array defined for thplot. I am trying to get the inital plot of the function to make an estimated guess to evaluate my function at the built in fzeros function.
The error just says
error in line "fplot=f(thplot);"
why is it not able to evaluate the function f @ thplot?
%Feilder Throwing Ball to Catcher
%Define the function who's zeros we're looking for
format longthrew
Vo=30; % velocity initial in m/s
y=-.8; %Final height of the ball after throw (1.8m start to 1m finish)
x=90; %Distance the fielder threw the ball
g=9.81;%gravity
f= @(th) x*tan(th*pi/180)-(g*x^2/(2*Vo^2*(cos(th*pi/180)^2)))+y;
%plot the function to get idea for initial guess
thplot=[0:70];
fplot=f(thplot);
plot(thplot, fplot, 'b', thplot, fplot*0, 'r--')
xlabel('theta');
legend ('fplot', 'y=0');
xlabel(theta);
legend('F(theta)', 'y=0');
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!