I am trying to write data to a file where the first column is the time values and the second column is the volts values.
4 views (last 30 days)
Show older comments
When I run my code instead of the all the time values going in one column and all the volts going in the other, it creates a matrix with two columns but fills both columns with time values until it reaches the end then starts to fill in volts.
%store data in a file called scaledLigo
data= [new_t_array2;scaled_volts];
fileID = fopen('scaledLigo.txt','w');
fprintf(fileID,'%6.8f %12.8f\n',data);
fclose(fileID);
0 Comments
Accepted Answer
Jon
on 1 Dec 2021
I think the problem is tha fprintf writes the elements columnwise. You could send the transpose (use the ' operator)
fprintf(fileID,'%6.8f %12.8f\n',data');
and I think you will get what you want
0 Comments
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT-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!