필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to Write Each Each Expression in a Separate Row

조회 수: 2 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2016년 8월 16일
마감: MATLAB Answer Bot 2021년 8월 20일
What is the best way to write every expression beneath each other (not in a single row)
if A == 1 && B == 2 && C == 3
D = 4
end
if A == 1 &&
B == 2 &&
C == 3
D = 4
end

답변 (4개)

Robert
Robert 2016년 8월 16일
You can use three dots (ellipsis) to extend MATLAB code onto the next line.
if A == 1 && B == 2 && C == 3
D = 4
end
becomes something like (according to your preferences for where to break the lines)
if A == 1 && ...
B == 2 && ...
C == 3
D = 4
end

Bhavesh Bhatt
Bhavesh Bhatt 2016년 8월 16일
I hope this helps
if A == 1
if B == 2
if C == 3
D = 4;
end
end
end

Walter Roberson
Walter Roberson 2016년 8월 16일
Use the ... continuation operator.
It is matter of taste as to whether you prefer
if A == 1 && ...
B == 2 && ...
C == 3
D = 4
end
or
if A == 1 ...
&& B == 2 ...
&& C == 3
D = 4
end
I tend to prefer the operator on the end of the line, but there is no right or wrong about that.

Star Strider
Star Strider 2016년 8월 16일
I don’t know the reason you would want to do that for that particular section of code. To continue code on multiple lines, you need to use the continuation operator, ‘...’.
See the documentation for Continue Long Statements on Multiple Lines for details.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by