loop txt files and save files

1 回表示 (過去 30 日間)
addy fang
addy fang 2020 年 7 月 10 日
編集済み: addy fang 2020 年 7 月 10 日
I do not have much knowledge in Matlab, but want to do the following, and need help.
I have two excel files, each has five columns of data. I need to add each column data in these two files with varying percentages in a loop, and save the new data in a series of files with the percentage in the files' names. Example:
%%%%%%%input data1%%%%%%%%%%%%%%%
data1=importdata('rawdata1.txt');
f1=data1(:,1);
e11=data1(:,2);
e12=data1(:,3);
u11=data1(:,4);
u12=data1(:,5);
%%%%%%%input data2%%%%%%%%%%%%%%%
data2=importdata('rawdata2.txt');
f2=data2(:,1);
e21=data2(:,2);
e22=data2(:,3);
u21=data2(:,4);
u22=data2(:,5);
%%%%%%%%%%%%%%%composite data%%%%%%%%%%%%
for x=0:0.1:1
data="Data"+x
f=x*f1+(1-x)*f2;
e1=x*e11+(1-x)*e21;
e2=x*e12+(1-x)*e22;
u1=x*u11+(1-x)*u21;
u2=x*u12+(1-x)*u22;
%%%%%%%%%save in data
data(:,1)=f;
data(:,2)=e1;
data(:,3)=e2;
data(:,4)=u1;
data(:,5)=u2;
xlswrite('data',data);
end;
  9 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 10 日
Notice that what I posted is
xslwrite(filename, data);
What you did instead is
xslwrite('filename', data);
addy fang
addy fang 2020 年 7 月 10 日
編集済み: addy fang 2020 年 7 月 10 日
Thank Walter and Madhan a lot for the great help!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangePID Controller Tuning についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by