Program output is correct but not plotting anything
2 ビュー (過去 30 日間)
古いコメントを表示
I've written a program in MATLAB that prints data that is correct but when I attempt to plot these values nothing comes up.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/236363/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/236363/image.jpeg)
0 件のコメント
採用された回答
Nicolas B.
2019 年 8 月 30 日
Hi Griffin,
please in future, post your code into the post. It makes the life of others easier than having to read it into a figure.
In your case, the reason why it is not plotting a line is pretty simple. Your vectors "t" and "thrust_force" are in fact scalars because the for loop uses t as an "index" and you erase thrust_force variable at each iteration.
I would recommand you to write your loop like that:
% create vector t and thrust_force to avoir resizing at each iteration
t = 0:80;
thrust_force = NaN(size(t)); % init it with a vector of NaN of the size of t
% loop with ii as index of t and thrust_force
for ii = 1:numel(t)
thrust_force(ii) = tug_thrust(t(ii));
end
Regards
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!