How can I export data set from Matlab to excel ?

24 ビュー (過去 30 日間)
Ardit Berisha
Ardit Berisha 2022 年 5 月 23 日
コメント済み: Voss 2022 年 5 月 25 日
Hello.
I have received a data set in Matlab. I would now need to export this to excel. Since I am not a big Matlab expert I have no idea how to do this...
I already tried it by just copy and paste, however the amount of data is too big for excel if you just copy and paste it.
So if I knew how to do it I would do it like this:
I would not transfer the data 1:1 but try to summarize always 10 "rows", so make the average of each 10 rows.
The average value of 10 lines corresponds to about 0.1 seconds for this data set.
I would be glad about your help !

回答 (1 件)

Jan
Jan 2022 年 5 月 23 日
編集済み: Jan 2022 年 5 月 23 日
The maximum number of rows in Excel is 1'048'576, while it can work with 16'384 columns. This means, that you cannot store vectors with 1'065'484 elements in an Excel file.
You can reduce the size by bildung the mean value of blocks: See e.g. FileExchange: BlockMean
For vectors:
data = load('untitled.mat');
data.EngPwr = BlockMenaV(data.EngPwr)
... etc.
T = struct2table(data);
writetable('YourExcelFile.xlsx');
function Y = BlockMeanV(X, W)
S = numel(X);
M = S - mod(S, W);
if M == 0
Y = X([]); % Copy type of X
else
XM = reshape(X(1:M), M, M / W); % Cut and reshape input
Y = sum(XM, 1) / W;
if iscolumn(X)
Y = Y(:);
end
end
end
  2 件のコメント
Ardit Berisha
Ardit Berisha 2022 年 5 月 25 日
i changed the excel name to "Lasten.xlsxs".
But why do i get this error ?
Voss
Voss 2022 年 5 月 25 日
@Ardit Berisha: You get that error because you are calling BlockMeanV with one input:
Sim.EngPwr = BlockMeanV(Sim.EngPwr);
% ^^^^^^^^^^ one input
but BlockMeanV expects two inputs:
function Y = BlockMeanV(X, W)
% 1 2 <- two inputs
S = numel(X);
M = S - mod(S, W); % <- W is used here. What happens if it was not given? The error you see.
% ...
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by