How do I change the matlab so that data is written in one column and several lines?
7 views (last 30 days)
Show older comments
In matlab the standard is to record the data of a variable in a row and multiple columns, however I noticed that in this configuration the processing time is much higher. How do I change the matlab so that data is written in one column and several lines?
0 Comments
Answers (2)
Thorsten
on 16 Sep 2015
I do not know of a "standard to record the data of a variable in a row and multiple columns"; what application are you referring to?
If you want to convert from row vector 1xN to column vector Nx1, use the colon operator :
x = x(:);
6 Comments
Stephen23
on 17 Sep 2015
Edited: Stephen23
on 17 Sep 2015
@Jesse Gomes: I saved your function as a text file and uploaded it as an attachment. This is preferred to placing large amounts of code as text (it is easier to download the whole file, and most people will not bother to scroll through or read long code).
In future you can upload files yourself by using the paperclip button above the textbox. There are also buttons for formatting code and other useful stuff that make them worth a look.
Your code also used mixed leading tabs and spaces, so I replace them all with spaces. It pays to be consistent within one file.
Walter Roberson
on 17 Sep 2015
In any operation upon pure vectors (arrays in which all except one dimension are length 1), the speed of processing rows or columns is exactly the same. MATLAB stores all vectors as consecutive entries in memory.
When you start working with arrays that are 2 or more dimensions, some operations may be faster along the first dimension, processing "down columns". The difference becomes more noticeable when the arrays extend to megabytes; for anything much smaller it usually is not worth the effort to change the code.
0 Comments
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!