Effacer les filtres
Effacer les filtres

loop txt files and save files

2 vues (au cours des 30 derniers jours)
addy fang
addy fang le 10 Juil 2020
Modifié(e) : addy fang le 10 Juil 2020
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 commentaires
Walter Roberson
Walter Roberson le 10 Juil 2020
Notice that what I posted is
xslwrite(filename, data);
What you did instead is
xslwrite('filename', data);
addy fang
addy fang le 10 Juil 2020
Modifié(e) : addy fang le 10 Juil 2020
Thank Walter and Madhan a lot for the great help!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by