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);
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!