필터 지우기
필터 지우기

loop txt files and save files

조회 수: 2 (최근 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 CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by