How do I change the matlab so that data is written in one column and several lines?
Afficher commentaires plus anciens
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?
Réponses (2)
Thorsten
le 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 commentaires
Jesse Gomes
le 16 Sep 2015
Thorsten
le 16 Sep 2015
What exactly do you mean by "record some values"? What function are you using to get these values?
Jesse Gomes
le 16 Sep 2015
Thorsten
le 16 Sep 2015
It's not Matlab per se, but your program that uses this storage scheme. You have to change it in the program. Also, the program may be vectorized to get rid of the for loop. It would be helpful if you post this program.
Jesse Gomes
le 17 Sep 2015
Modifié(e) : Stephen23
le 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
le 17 Sep 2015
0 votes
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.
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!