'For ' loop iteration for xls read and write.

조회 수: 2 (최근 30일)
Maria Imdad
Maria Imdad 2020년 11월 25일
댓글: Maria Imdad 2020년 11월 25일
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');
  댓글 수: 1
Maria Imdad
Maria Imdad 2020년 11월 25일
thank you so much... it worked perfectly for me

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by