How can I export data set from Matlab to excel ?

조회 수: 17 (최근 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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by