フィルターのクリア

How to show each iteration in for loop?

5 ビュー (過去 30 日間)
Antonio Hamilton
Antonio Hamilton 2021 年 5 月 11 日
コメント済み: Antonio Hamilton 2021 年 5 月 12 日
initialX = input('\nWhat would you like your starting x value to be?\n');
initialY = input('\nWhat would you like your starting y value to be?\n');
xo = initialX;
yo = initialY;
dydx = 0;
for j = xo:deltaxem:sizeOfGraphXPositive
xo = j;
yo = yo + (dydx .* deltaxem);
dydx = xo + yo;
plot(xo, yo, '*', 'linewidth', 4); hold on
xlim([-sizeOfGraphXPositive sizeOfGraphXPositive]);
ylim([-sizeOfGraphYPositive sizeOfGraphYPositive]);
axis equal
title("Euler's Method");
xlabel('X Values');
ylabel('Y Values');
end
  2 件のコメント
James Tursa
James Tursa 2021 年 5 月 11 日
What specifically do you mean by "show each iteration"? What do you want to have happen that your current code doesn't do?
Antonio Hamilton
Antonio Hamilton 2021 年 5 月 11 日
I want to display the iterations of xo, yo, and dydx in a table. Specifc xo and yo values correspond to the value of dydx. However, I am not sure how to display a value that was iterated inside the for loop, outside of the for loop.

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

採用された回答

Chunru
Chunru 2021 年 5 月 12 日
Add this after dydx=... line:
fprintf('xo = %10.5f yo = %10.5f dydx = %10.5f \n', xo, yo, dydx);
  1 件のコメント
Antonio Hamilton
Antonio Hamilton 2021 年 5 月 12 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by