フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to export a txt file

1 回表示 (過去 30 日間)
Pouyan Msgn
Pouyan Msgn 2020 年 5 月 7 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a txt file here but there is a problem in the X-axis and I have to reduce it by the value 1.4
I did it in Matlab but I failed to save it as new txt file
Here is my attempt:
clc
clear all
D398=importdata('J398.txt');
X=D398(:,1)-(1.4); Y=D398(:,2);
A=[X Y];
fileID = fopen('NewFile.txt','w');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);
The Y axis in the NewFile is not the same as before!
  2 件のコメント
Andreas
Andreas 2020 年 5 月 7 日
Hello,
generally speaking arrays in MATLAB are stored in a column major fashion. In this case matrix A is first converted columnwise into a vector and then its components are sequentially written out to file.
To get the desirable outcome, the following line of code needs to be instead used,
fprintf(fileID,'%6.2f %12.8f\n',A.');
Kind Regards,
Andreas
Pouyan Msgn
Pouyan Msgn 2020 年 5 月 7 日
Hi thank you!

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by