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
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
george veropoulos am 20 Mai 2023
Bearbeitet: Walter Roberson am 20 Mai 2023
hi thank you
variable=table(Z12' ,Y', bin', values')
writetable(variable ,'hreal.txt')
i receive the message
Error using table (line 231)
All table variables must have the same number of rows.
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.
Could sent a example with cell ?
%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');
thank ! but i receive an error
Error using writecell (line 146)
The data block starting at cell 'A1' exceeds the sheet boundaries by 34466
row(s) and 0 column(s).
Error in impedance_antennaR_h (line 103)
writecell(overcell, 'FileNameGoesHere.xls');
I change he format of file to xlsx and work !! thank you !!!
There are limits on the number of rows for xls files. There are higher limits for xlsx files, a little over 1 million rows.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by