How to export "duration" output and "symbolic variables" in excel file ?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Walter Roberson
2018-3-21
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)
0 个评论
Jan Siroky
2018-3-21
Duration can be converted to numeric using functions such as days or hours.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!