How to export the result of for loop to the excel file
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
kaivlya patel
el 21 de Mayo de 2020
Comentada: KSSV
el 21 de Mayo de 2020
Hi all
I have the following code,
for n = 2: frontier_idx
plot (pareto_frontier (n: frontier_idx, 2), pareto_frontier (n: frontier_idx, 3), 'rs' , 'LineWidth' , 3, 'Tag' , sprintf ( 'ix% d \ n% s' , 1, join ( pareto_frontier_archs (n, :))))
end
for k = 1: length (pareto_frontier (:, 2))
fprintf ( 'x =% f, y =% f. \ n' , pareto_frontier (k, 2), pareto_frontier (k, 3));
end
and the answer of this code, I get is:
x = 4,200,000, y = 6,819,000.
x = 4.040000, y = 6.808000.
x = 4.000000, y = 6.797000.
x = 3.870000, y = 6.568000.
x = 3.570000, y = 6.380000.
x = 3.530000, y = 6.369000.
x = 3.370000, y = 6.358000.
x = 3.330000, y = 6.347000.
x = 3,200,000, y = 6,118,000.
x = 3.070000, y = 5.901000.
x = 3.030000, y = 5.890000.
x = 2,900,000, y = 5,661,000.
Now, I want to export this x and y coordinate values, which I have got from the above code, to the excel / macro excel file. I have already generated the excel file with the writematrix command to export some prior data. And for the prior data it is working properly but comming to the above for loop and its result, it is not working.
I have tried xlswrite function and also the writematrix / writecell function tso do so, but it is not working. The reason to use writematrix is that firstly the file I kept was excel macro file. But when it was not working, I tried to do the same with the normal .xls file. But the result is not being exported to any of the excel file.
Any help in this perticular would be really appreciated and I would be really greatful.
0 comentarios
Respuesta aceptada
KSSV
el 21 de Mayo de 2020
A = pareto_frontier(:,2:3) ;
xlswrite('test.xlsx',A)
Also have a look on write2table.
2 comentarios
Más respuestas (0)
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!