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.

조회 수: 3 (최근 30일)
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);

채택된 답변

Jon
Jon 2021년 12월 1일
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개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by