Need help plotting multiple functions using fplot and subplot
8 ビュー (過去 30 日間)
古いコメントを表示
Larry Burroughs
2016 年 10 月 27 日
回答済み: Walter Roberson
2016 年 10 月 28 日
We have been learning to use fplot and subplot in class and I am supposed to:
First, create a function with the height as the output and with time, velocity, and angle as inputs. Next, use your function using fplot and subplot, make one plot with 4 subplots, letting theta equal 30, 45, 60, and 70. Let t go from 0 seconds to 2 seconds for each plot. Make sure to label each plot and all axes.
I am having a hard time getting MATLAB to plot four instances of a function. I have included the code for my function and script below. Any help would be greatly appreciated.
function h = proj_motion (t,v,ang)
h_i = 1;
g = 9.81;
h = (-1/2).*g.*((t)^2)+(v*sin(ang))*t+h_i;
end
%==========================Script Below================================
t_int = [0:.1:2];
figure
subplot(2,2,1)
fplot(proj_motion(t_int,10,30),y,t_int)
subplot(2,2,2)
fplot(proj_motion(t_int,10,45),y,t_int)
subplot(2,2,3)
fplot(proj_motion(t_int,10,60),y,t_int)
subplot(2,2,4)
fplot(proj_motion(t_int,10,70),y,t_int)
0 件のコメント
採用された回答
Walter Roberson
2016 年 10 月 28 日
Example:
fplot(@(x) x, [1 2])
hold on
fplot(@(x) x.^2, [1 2])
fplot(@(x) x.^3, [1 2])
hold off
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!