Write string into excel
94 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sangay Nidup
el 19 de Sept. de 2019
Comentada: darova
el 20 de Sept. de 2019
Hi, my excel file (Book2) contains 20x3 arrays with integer values. I want to run the following 'for loop' and 'if loop' with logical operations on Matlab and then write 'string' values in a new column of the same excel file. Please help me to correct the code. Thanks.
F = xlsread('Book2.xlsx');
N = length(F(:, 2));
for i = 1 : N
if ((F(i, 2) >= 7 && F(i, 2) < 27) && (F(i, 3) >= 28 && F(i, 3) < 50) && (F(i, 1) <= 52))
xlswrite('F.xlsx', (i, 4), {'Loam'});
else
xlswrite('F.xlsx', (i, 4), {'Null'});
end
end
0 comentarios
Respuesta aceptada
darova
el 19 de Sept. de 2019
I suggest you to write all you want in cell array then write it to Excel file
A = cell(5,1); % preallocate cell array
for i = 1:5
if mod(i,2)
A{i} = 'hi';
else
A{i} = 'by';
end
end
fname = 'b.xlsx';
sheet = 2;
xlRange = 'A1';
xlswrite(fname,A,sheet,xlRange) % write cell array into 2d sheet on A1 position
4 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!