How do I change the matlab so that data is written in one column and several lines?

7 views (last 30 days)
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?

Answers (2)

Thorsten
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
Jesse Gomes
Jesse Gomes on 17 Sep 2015
Edited: Stephen23 on 17 Sep 2015
Dear Thorsten,
please find below the function. All variables contains only zeros and ones.
BR
Stephen23
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.

Sign in to comment.


Walter Roberson
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.

Community Treasure Hunt

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

Start Hunting!