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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (2)

Walter Roberson
Walter Roberson il 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 il 21 Mar 2018
Duration can be converted to numeric using functions such as days or hours.

Community Treasure Hunt

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

Start Hunting!

Translated by