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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 10월 29일

편집:

2013년 10월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by