trouble using iterations and plotting

Got it thanks!

3 件のコメント

Michael Haderlein
Michael Haderlein 2014 年 9 月 15 日
In your code, there is no part where the function is evaluated. You just count t from 6.8 to 17.8. You need t as array:
t=linspace(6.8,17.9);
Then evaluate your function (just copy the function definition from your question). Plot as you did before. There's no need for a loop in this case.
George  Zimbodia
George Zimbodia 2014 年 9 月 15 日
編集済み: George Zimbodia 2014 年 9 月 15 日
Got it thanks!
Star Strider
Star Strider 2014 年 9 月 15 日
Please don’t delete or erase the text of your original Question. Doing so eliminates the context others may need if they have the same problem and search MATLAB Answers for a solution.

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2014 年 9 月 15 日

0 投票

‘The question is a practice problem from a professor. The question asks me to use for and/or while loops’
Using a while loop:
t = 6.8;
k = 1; % Initialise Counter
while (t >= 6.8 && t <= 17.9)
f(k) = 3.98*t.*exp(52.65*(t-9.4));
t = t +.1;
tv(k) = t;
k = k+1;
end
figure(89)
plot (tv,f)
You have to keep track of ‘t’ and ‘f’ as vectors regardless of using a while or for loop. There are several ways of using a for loop for this problem, so I’ll let you experiment with them, since this is homework.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by