フィルターのクリア

How to ignore new values?

6 ビュー (過去 30 日間)
Tristan
Tristan 2013 年 10 月 29 日
編集済み: sixwwwwww 2013 年 10 月 29 日
for example, if I have:
>> p1=5;p2=3;
and I want to calculate:
>> p1=p1-p2;p2=p1+p2
p2 =
5
because matlab has already calculated the new value for p1, but I want it to ignore new values until the end of the second line, so that p2=8

採用された回答

sixwwwwww
sixwwwwww 2013 年 10 月 29 日
編集済み: sixwwwwww 2013 年 10 月 29 日
Dear Tristan, you can do it as follows:
p1 = 5; % initialize p1
a = p1; % store p1 value in new variable to use later
p2 = 3; % initialize p2
p1 = p1 - p2; % overwrite value of p1
p2 = a + p2; % use old value of p1 to overwrite p2
I hope it helps. Good luck!

その他の回答 (0 件)

カテゴリ

Help Center および 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