How to add "..." to multiple lines

6 次查看(过去 30 天)
Hi,
I think I have a simple question. I pasted a large number of 3D points into an mfile. There are N >10000 points and each is on a separate line i.e.
1 2 3
4 5 6
7 8 9
...
I want to assign the whole mess to one 3Nx1 vector. Is there an easier way to do this than putting [] around it and ... at the end of each line? That is, is there a way to tell Matlab to ignore line breaks for a section (and say replace them with tabs)? Or another creative solution?
Thanks. It seems a little silly, but I'd love to avoid spending my afternoon pasting "..."s...
-greg

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-11-4
There is a better way. I assume you pasted the data so the data has multiple lines. You only need to add one "[" at the beginning of the first line and add one "]" at the end of the last line to make it a matrix. Then you can reshape it to a vector.
a=[1 2 3
4 5 6
7 8 9];
b=a';
b=b(:)
  1 个评论
Greg
Greg 2011-11-4
Ah! Thanks. I had no idea you don't need the ";..." when writing matrices on multiple lines. That is fantastic.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by