Hello everyone I am trying to write something like:
x=input('x value: '); y=input('y value: ');
k=x*y;
if k=6 k1=2; elseif k=0 k1=1; end
How can i write that with that statement and no error? Thank you!

 채택된 답변

James Tursa
James Tursa 2020년 5월 4일
편집: James Tursa 2020년 5월 4일

0 개 추천

x = input('x value: ');
y = input('y value: ');
k = x * y;
if k == 6 % <-- Use == for equality test
k1 = 2;
elseif k == 0
k1 = 1;
end
Note that there is a path for k1 to be unset if k is not 6 or 0. You might need to cover this case in your code.

추가 답변 (0개)

태그

질문:

2020년 5월 4일

댓글:

2020년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by