Write vectors of different size in text file
Mostra commenti meno recenti
Hello everybody,
I would like to write some data to a text-file. Unfortunately the dimensions of the data are not the same, so I get the error:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Filename_txt = 'Dummy.txt'
data = [Angle Velocity Distance Acceleration]';
fidwrite = fopen(Filename_txt, 'wb');
fprintf(fidwrite, '%s\t %s\t %s\t %s\n', 'Angle[deg]','Velocity[mm/s]','Distance [mm]', 'Acceleration [mm/s^2]');
status = fprintf(fidwrite, '%4.5f\t %4.5f\t %4f.5\t %4.5f\n', data);
fclose(fidwrite);
disp (['txt-File ' Filename_txt ' created']);
Is it possible to write the data into one text-file even though they differ in their dimensions?
Thank you
Christian
4 Commenti
Adam
il 1 Feb 2017
What are the varying dimensions and what do you want the text file to show for cases where one heading has more data than others?
Christian
il 1 Feb 2017
Adam
il 1 Feb 2017
But where do the extra 6 values come from? Are they just on their own at the end? Do the previous 274 match up to the 274 of the Distance vector or are there just 6 values missing from the Distance vector at arbitrary locations?
You can probably just pad your shorter vectors with NaNs if the extra numbers are all at the end. Then they will all be the same size.
Christian
il 1 Feb 2017
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Labels and Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!