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

8 visualizaciones (últimos 30 días)
ahmad Al sarairah
ahmad Al sarairah el 3 de Jun. de 2019
Respondida: Murugan C el 3 de Jun. de 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)?

Respuestas (2)

Raj
Raj el 3 de Jun. de 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?

Murugan C
Murugan C el 3 de Jun. de 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');

Categorías

Más información sobre Data Export to MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by