Copy-pasting variables (values) to edior in 2021b
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Copy-pasting column vector values from workspace to editor used to automatically include ; and give me everything in a nicely formated single row. After updating to 2021b it results in a long list of values (each one in a separate row).
For example:
Create a column vector:
> A = [1; 2; 3; 4; 5];
Open it in the workspace, select entire column and copy (ctrl-c)
Paste in the editor results with:
1
2
3
4
5
while it used to result with:
1;2;3;4;5
Is there a way to switch back to the old behavior of copy-pasting variables?
I use it a lot, for example when saving the results in my scripts as starting values for the future and the new format makes the scripts much longer and messier.
Thank you very much in advance for any suggestions.
1 Kommentar
Seok Yoon Jeong
am 24 Nov. 2021
I meet same issue in R2021b.
The previous version did wonderful job. why they eliminiate it?
Have you fix this problem?
Antworten (4)
DGM
am 23 Okt. 2021
Bearbeitet: DGM
am 23 Okt. 2021
Just don't rely on some sort of automagic formatting of pasted content. If you want to save an array variable as a literal constant, just convert it according to your needs using mat2str() or something.
A = rand(5,1) % a test array
mat2str(A,5) % or however many digits you want
A = randi(9,5,1) % same thing, but integers
mat2str(A) % again
mat2str() will give you an expression which can simply be copied and pasted.
Otherwise, you can always just save the variables to a mat file or something and load them as needed.
4 Kommentare
DGM
am 7 Jan. 2022
Workarounds are generally terrible by definition when compared to a scenario which obviates the necessity for workarounds.
If you know of a better workaround to which the one I offered is by far worse, feel free to post it. That's not sarcarsm. I have no stake in this.
For what it's worth, I don't use R2021x, and I doubt I ever will. The creeping integration of these new UI components is gradually breaking everything for me. I don't need MATLAB to be slower and flakier than it already is.
Walter Roberson
am 7 Jan. 2022
Put a [ in your code and then paste and then put a ]
The line breaks inside [] are treated as semi-colon
2 Kommentare
Walter Roberson
am 22 Jul. 2022
I do not know. I would tend to think that level would be built in functions, not matlab code.
fer ef
am 16 Aug. 2024
I encounter the same problem in 2021b. While others above say that mat2str() works, I found the following is more easy to use. That is, paste the text first in the command line.
For unknown reason, pasting in the command line will produce the results: [1;2;3;4;5] as previous Matlab versions. However, pasting in the edition produces
1
2
3
4
5
Therefore, it would be convenient to paste in the command line firstly and then recopy the texts from the command line.
It works fine for me
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!