What loops do I use?

4 ビュー (過去 30 日間)
Kristen A
Kristen A 2020 年 4 月 15 日
回答済み: Walter Roberson 2020 年 4 月 15 日
I have an already created code below.
If I had to use loops in order to produce the same output (as the original code), what loops would I need to use and how? What would the code look like?
T=0:0.01:20;
V0=100;
G=9.8;
theta=pi/4;
HT=T*V0*cos(theta);
plot(T,HT);
title('horizontal path');
xlabel('time(s)');
ylabel('distance(m)');
%%
T=0:0.01:20;
V0=100;
G=9.8;
theta=pi/4;
VT=(T*V0*sin(theta))-((1/2)*G*T.^2);
plot(T,VT);
title('vertical path');
xlabel('time(s)');
ylabel('distance(m)');

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 4 月 15 日
https://www.mathworks.com/matlabcentral/answers/504285-for-loop-for-non-consecutive-values-in-an-array#answer_414399

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by