disp
조회 수: 14 (최근 30일)
이전 댓글 표시
if b>a & b>c
disp(b)
elseif c>a & c>b
disp(c)
else disp(a)
disp(a)
end
I have defined:
>> a
a =
24
>> b
b =
42
>> c
c =
64
when I run this the if/else works and i get 64
but it does not disp a afterwards. Why not?
댓글 수: 1
Jan
2011년 10월 31일
You can copy the lines to a function and use the debugger to step through the code line by line. This is usually more helpful for learning than letting Walter find the problem.
채택된 답변
Walter Roberson
2011년 10월 31일
The final disp(a) is within the scope of the last else. "else" does not terminate until an "end" -- you are not limited to providing only a single statement in an if or elseif or else clause.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Transmitters and Receivers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!