MATLAB Answers

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

13 views (last 30 days)
ahmad Al sarairah on 3 Jun 2019
Answered: Murugan C on 3 Jun 2019
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)?

#### 0 Comments

Sign in to comment.

### Answers (2)

Raj on 3 Jun 2019
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?

#### 0 Comments

Sign in to comment.

Murugan C on 3 Jun 2019
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');

#### 0 Comments

Sign in to comment.

Sign in to answer this question.

R2018a