save thw values of four variable in a file
Ältere Kommentare anzeigen
Hi
i want to save four variable from a matlab code in a file ( like xls)
the two from four value have many values (10000)
thank
George
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 20 Mai 2023
0 Stimmen
If you do not need headers, put them in a vector and writematrix.
If you need headers create a table() and writetable
7 Kommentare
george veropoulos
am 20 Mai 2023
Bearbeitet: Walter Roberson
am 20 Mai 2023
Walter Roberson
am 20 Mai 2023
It is a bit tricky to get xls files that have different numbers of rows for each variable. You can writetable() one at a time specifying 'Range' to indicate where in the file the results should go. Or you can put all of the values into a cell (including the headers as the first row) with empty cells for the places with no values, and then writecell() . Or you can pad the shorter variables with NaN: NaN show up as empty when you view xls files.
george veropoulos
am 20 Mai 2023
Walter Roberson
am 21 Mai 2023
%build cell to hold values. We count on automatic extension of the cell
%array if some of the rows are longer than what already exists
overcell = num2cell(Z12(:));
overcell(1:numel(Y),2) = num2cell(Y(:));
overcell(1:numel(bin),3) = num2cell(bin(:));
overcell(1:numel(values),4) = num2cell(values(:));
%insert header
overcell = [{'Z12 (V/mm)', 'Y (Ohm/Hz)', 'bin (F/J)', 'values (furlong/fortnite)'};
overcell];
%write it out
writecell(overcell, 'FileNameGoesHere.xls');
george veropoulos
am 21 Mai 2023
george veropoulos
am 21 Mai 2023
Walter Roberson
am 21 Mai 2023
There are limits on the number of rows for xls files. There are higher limits for xlsx files, a little over 1 million rows.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!