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.

7 views (last 30 days)
Jess on 1 Dec 2021
Answered: Jon on 1 Dec 2021
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);

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!