Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to Write Each Each Expression in a Separate Row
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(4 个)
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
0 个评论
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.
0 个评论
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, ‘...’.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!