hi. i have two variables which are AREA and PERIMETER.

1 view (last 30 days)
how to save both variables in a mat.file? i only have coding for one variable only :
_ _ _objArea = objMeasurements(k).Area; % Get area.
AREA=[objArea;AREA];
save('AREA.mat','AREA');
objPerimeter= objMeasurements(k).Perimeter; % Get perimeter.
PERIMETER=[objPerimeter;PERIMETER];
save('PERIMETER.mat','PERIMETER');___
  1 Comment
Varun Pai
Varun Pai on 13 Oct 2015
Save all the variables into a single matrix. Then you can save it as a Mat

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 13 Oct 2015
save(Filename, 'AREA', 'PERIMETER')
  3 Comments
Walter Roberson
Walter Roberson on 15 Oct 2015
You can specify a folder name when you save().
To save both values as columns in a single variable:
AREA_PERIMETER = [AREA, PERIMETER];
save(Filename, 'AREA_PERIMETER');

Sign in to comment.

More Answers (1)

Stephen23
Stephen23 on 13 Oct 2015
You could do this in two calls:
save(filename,'AREA')
... other code
save(filename,'PERIMETER','-append')
OR in one call:
save(Filename, 'AREA', 'PERIMETER')
  1 Comment
hudazin
hudazin on 15 Oct 2015
Edited: hudazin on 15 Oct 2015
i already tried it. but it only save in MAT.file but different folder. i want AREA and PERIMETER together in two column in one MAT.file. i want 14X2.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!