'For ' loop iteration for xls read and write.

3 次查看(过去 30 天)
Hi everyone,
I am new to matlab, I am facing a problem. I have this piece of code where i am taking value from one column (128 bits, as zero and one only) of an excel file and after some steps, it gives me 11 new values of same length. right now i am manually saving these values as given below:
key_out=xlsread('key.xlsx','A:A');
for i=1:11
%some steps giving me 11 new values as 128 bit strings
%
%
jj=key_out;
C(i,:)=jj(); %saving values into a matrix to write into excel.
end
Results_Values=[C];
filename = 'DATASET.xlsx';
sheet=1;
xlRange=strcat('A1:K128');
xlswrite(filename,Results_Values,sheet,xlRange);
Now in the given code i have to chnage the value of column for both read and wite file. Right now i have to manually change 'A:A: to 'B:B' for xlsread and for xlswrite i will update value of column from 'A1:K128' to 'L1:V128'. doing this for small interval is fine but i have to do it for more than 50 files using xlsread.
All i need is your help to design a loop which iterates through column by coulmn for read but for write 11 column/rows.
Thank you.

采纳的回答

David Hill
David Hill 2020-11-25
key_out=readmatrix('key.xlsx');%read all at once and then index
for j=1:12
for i=1:11
end
C(i,:,j)=jj();
end
writematrix(C,'DATASET.xlsx');

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by