
Starting a new line
97 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
1582251394
am 24 Mär. 2016
Kommentiert: Walter Roberson
am 4 Feb. 2025 um 22:41
Hi I'm really new to MATLAB. My questions is how to a start a new line without executing the code. For example if I have:
y = 1123414124124124124 (want new line here without executing)
0 Kommentare
Akzeptierte Antwort
Meghana Dinesh
am 24 Mär. 2016
Bearbeitet: Meghana Dinesh
am 24 Mär. 2016
Are you typing your code in the Command Window? Then use "..." and < enter >

But I suggest you start typing your code in a script. (Home > New > Script)
2 Kommentare
Walter Roberson
am 4 Feb. 2025 um 22:41
Note that in modern versions of MATLAB, the "..." operator has an implied seperator before it.
In sufficiently old versions of MATLAB,
[123....
456]
would have been treated as 123.456. In modern versions of MATLAB, it is treated the same as
[123. ...
456]
and so would result in [123. 456]
Side note: the parsing of literal constants takes priority over the ... operator. Entering
[123...
456]
is treated as "123." followed by ".." which is a syntax error.
But
A = 123;
[A...
456]
would be treated as [A 456] which would be [123 456]
Weitere Antworten (1)
Andrew
am 4 Feb. 2025 um 21:49
add ";" at the end, then click enter
1 Kommentar
Steven Lord
am 4 Feb. 2025 um 22:07
That will end the current command (or end the current row, if it appears inside square brackets or curly braces to create a matrix or cell array.)
x = 12345; % This is one statement
y = [1 2; % This ends the first row of matrix y
3 4]
z = {'apple'; % This ends the first row of cell array z
'banana'}
If you want to continue the command on the next line, using ... is probably the right thing to do.
q = 12345 + ... % Continue the statement on the next line
67890 % These two lines are the equivalent of "q = 12345 + 67890"
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!