saving multiple structures to a .mat file
Show older comments
I am trying to save multiple structures to one .mat file. This is needed because I am interfacing Matlab and GAMS (an optimization solver). However, when I run the code you see below, i get the message
'Error using save Saving from multiple structures is not supported.'
Does anyone know a way around this?
%%Pelmax
Pelmax.name='Pelmax';
Pelmax.val=[0; 0; 0; 0;];
Pelmax.form='full';
Pelmax.type='parameter';
%%Pelmin
Pelmin.name='Pelmin';
Pelmin.val=[0; 0; 0; 0;];
Pelmin.form='full';
Pelmin.type='parameter';
%%Pthmax
Pthmax.name='Pthmax';
Pthmax.val=[0; 0; 0; 0;];
Pthmax.form='full';
Pthmax.type='parameter';
%%Pthmin
Pthmin.name='Pthmin';
Pthmin.val=[0; 0; 0; 0;];
Pthmin.form='full';
Pthmin.type='parameter';
%%a and b (relation Pel and Pth)
a_P.name='a_P';
a_P.val=[0; 0; 0; 0;];
a_P.form='full';
a_P.type='parameter';
b_P.name='b_P';
b_P.val=[0; 0; 0; 0;];
b_P.form='full';
b_P.type='parameter';
%%a and b (relation eta_el and Pel)
a_el.name='a_el';
a_el.val=[0; 0; 0; 0;];
a_el.form='full';
a_el.type='parameter';
b_el.name='b_el';
b_el.val=[0; 0; 0; 0;];
b_el.form='full';
b_el.type='parameter';
%%a and b (relation eta_th and Pth)
a_th.name='a_th';
a_th.val=[0; 0; 0; 0;];
a_th.form='full';
a_th.type='parameter';
b_th.name='b_th';
b_th.val=[0; 0; 0; 0;];
b_th.form='full';
b_th.type='parameter';
%%min up
minup.name='minup';
minup.val=[0; 0; 0; 0;];
minup.form='full';
minup.type='parameter';
%%min down
mindown.name='mindown';
mindown.val=[0; 0; 0; 0;];
mindown.form='full';
mindown.type='parameter';
%%save everything in one .mat-file
save('CHPS','-struct', 'Pelmax',...
'-struct', 'Pelmin',...
'-struct', 'Pthmax',...
'-struct', 'Pthmin',...
'-struct', 'a_P', ...
'-struct', 'b_P', ...
'-struct', 'a_el', ...
'-struct', 'b_el', ...
'-struct', 'a_th', ...
'-struct', 'b_th', ...
'-struct', 'minup', ...
'-struct', 'mindown')
Accepted Answer
More Answers (0)
Categories
Find more on String Parsing 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!