How to export "duration" output and "symbolic variables" in excel file ?

2 vues (au cours des 30 derniers jours)
Abhijit Deka
Abhijit Deka le 26 Oct 2016
I need to store the outputs of each iteration in my for loop in a excel file. Tried to use xlswrite(). However, the error I get is 'Input data must be a numeric, cell, or logical array.'
One of my outputs is a duration of the form '03:15:00' obtained from A = duration(10,0,0); and haven't been able to store this in any form.
The rest of my outputs are symbolic variables "1X1 Sym". I did store them using dummyarray(i,j) but I need the data in .xls. Please help !!
Thanks in advance, Abhijit

Réponses (2)

Walter Roberson
Walter Roberson le 21 Mar 2018
You can cellstr() the duration array to get a cell array of character vectors that you can include in the cell of data to be written by xlswrite()
For a sym array, with current versions of MATLAB, you can use
sym_cell = arrayfun(@char, YourSymArray, 'uniform', 0)
but in some of the older versions you could not arrayfun() a sym array; in those older versions sometimes a for loop was easier. But you could
sym_cell = arrayfun(@(IDX) char(YourSymArray(IDX)), reshape(1:numel(YourSymArray),size(YourSymArray)), 'uniform', 0)

Jan Siroky
Jan Siroky le 21 Mar 2018
Duration can be converted to numeric using functions such as days or hours.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by