How can I export variales from double and structure with different rows into excel?

8 views (last 30 days)
Hello everyone,
I have variables in 8x1 double, in 40x1 double under 1x1 struct, and 1x1 double. Since I have the same varibles for different trials saved in different MATLAB files, I was trying to save all the variables from each trial in a table first and export to a excel for all trials. Then, copy and paste variables from each excel for each trial, and put them all together in a new excel. But when I run the code for making a table (as shown below), it gets into an error:
Error using table (line 233)
All table variables must have the same number of rows.
EMGvariable.Properties.VariableNames{1} = 'AbdAngleMax';
EMGvariable.Properties.VariableNames{2} = 'AbdAngleMin';
EMGvariable.Properties.VariableNames{3} = 'AbdAngleChange';
EMGvariable.Properties.VariableNames{4} = 'speed';
EMGvariable.Properties.VariableNames{5} = 'FinSwingDist.dist';
EMGvariable.Properties.VariableNames{5} = 'TailSwingDist.dist';
Is there anything I could do to fix the issue? Or should I not use the table function?
Thank you very much for your help!
Mario Malic
Mario Malic on 1 Oct 2020
Edited: Mario Malic on 1 Oct 2020
Yes, that should work.
Edit: moving my comment to answers, since I tested it.

Sign in to comment.

Accepted Answer

Mario Malic
Mario Malic on 1 Oct 2020
These have to have same number of rows, which they don't, according to your first sentence.
Fill up your variables with NaN's to match the maximum number of rows that a variable has.

Sign in to comment.

More Answers (0)


Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by