How i can write array cell to excel sheet using loops?

조회 수: 3 (최근 30일)
ahmad Al sarairah
ahmad Al sarairah 2019년 6월 3일
답변: Murugan C 2019년 6월 3일
I am trying to write cell array contents from matlab to excel sheet , the cell array is (1x4) cell .
The first cell({1,1}) contains a string (glcm11) ,and the second cell({1,2}) contains (glcm12) ,the third cell({1,3}) contain (glcm13) , and the fourth cell is (glcm14) .
How i can write these cells to excel sheet using loops to range (a2:a5)?

답변 (2개)

Raj
Raj 2019년 6월 3일
What is the issue? Is this what you are looking for:
a{1,1}='glcm11';
a{1,2}='glcm12';
a{1,3}='glcm13';
a{1,4}='glcm14';
xlswrite('test.xls',a,'A2:A5')
"How i can write these cells to excel sheet using loops to range (a2:a5)" - What is the need to use loops?

Murugan C
Murugan C 2019년 6월 3일
Hi ahamd,
use below script.
% with for loop
input_data = {'glcm11','glcm12','glcm13','glcm14'};
for i = 1 : length(input_data)
write_data = input_data(i);
range = strcat('A',num2str(i+1));
xlswrite('new.xlsx',write_data,'sheet1',range);
end
% OR without for loop
input_data = {'glcm11','glcm12','glcm13','glcm14'}';
xlswrite('new.xlsx',input_data,'sheet1','A2');

카테고리

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by