Matlab matrix copy-paste problem (pasting a matrix into the Matlab Editor in older, 1-line format)

When I use R2022b, I copy a matrix from the Matlab table, it should be in this format"[1,1,1;0,0,0]", but it is in this format"1 1 1
0 0 0", how should I adjust to this format"[1,1,1;0,0,0]"?On the left is the Matlab table,the picture on the right shows two matrix display formats.

4 Comments

Please elaborate on "copyfrom the Matlab table". Do you mean from a uitable? From the variable editor? From the command window?
SImilar to what @Matt J said, I think you are confusing environments. The paste behavior, when copying from the command window or a uitable, will not be the same as when copying from the variable editor.
Thank you for your attention and reply to the problem. I have updated the problem and displayed pictures. I hope you can understand my problem and find a solution.
You may understand my problem, my obsession is that when I used R2018b before, as long as I copied from the matlab table to the matlab editor, it is a one-line format, the elements are separated by commas and semicolons, very convenient. I recently installed R2022b, it becomes a multi-line format after copying.

Sign in to comment.

 Accepted Answer

I don't think there is a preference setting that will restore the behavior you want. A workaround though is to copy/paste from the Variables Editor (the thing you've been calling the "Matlab table") to the Command Window, which will be in the format you want. You can then copy/paste from the Command Window to the Matlab Editor. See below:

1 Comment

Yes, this is what I need, although it is not directly copied to the script, but it is also very convenient, thank you

Sign in to comment.

More Answers (1)

Type the brackets [] at the desired location and paste into the space between them.

6 Comments

The pasting format was appropriate when earlier versions were used, but the current version pastes poorly. My matrix is very large, and I often need to copy and paste the matrix, the workload is a bit large, of course, there are some hard solutions, but I want to solve it from the Matlab setup or programming point of view, anyone know?
The pasting format was appropriate when earlier versions were used
You say you had the behavior you want in R2022b? I've never seen that, and I'm still on R2021b.
Why not just type the brackets, as I suggested?
I used the Matlab2018b version before, it can be pasted into 1 line. For example, a matrix is 100 rows and 100 columns, with the standard format, only occupies one line, if the original format, it takes 100 lines, so programming is more troublesome, the original code is 2,000 lines, because the matrix format, may increase thousands of lines. The programming is inconvenient. This is just my personal operating habits and programming preferences. I hope to be able to change the pasted matrix into a comma and semicolon separated format from the Matlab setting, which only takes up one line of my space.
See comments above. We still don't know what environment you are copying from and pasting to, though I'm guessing you're pasting to either the command line or the editor.
I copied from the matlab table to the script, first copying the matrix in excel to the Matlab table and then from the Matlab table to the script. This matrix display format should have a function can be controlled, but where is this function, I can not find.
As mentioned above, we don't know what you mean by "the Matlab table". It's not a thing.

Sign in to comment.

Tags

Asked:

Yu
on 6 Sep 2023

Edited:

on 6 Sep 2023

Community Treasure Hunt

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

Start Hunting!