how to Create a mat file for images

1 view (last 30 days)
i have 15 images say x1=[1 2
3 4 ]
similarly x2 =[5 6
3 4 ] , x3 till x15
first i want these to be converted to x1= [ 1
2
3
4]
similarly other matrixes also.
i want to save a mat file called
dark = [ 1 6
2 7
3 3
4 4]

Accepted Answer

Image Analyst
Image Analyst on 10 Apr 2015
A mat file called what?
Anyway, to save those variables:
save(matFileName, 'x1', 'x2, 'x3', 'x4', ...
'x5', 'x6', 'x7', 'x8', ...
'x9', 'x10', 'x11', 'x12', ...
'x13', 'x14', 'x15', 'dark');
  4 Comments
Sharen H
Sharen H on 12 Apr 2015
my data is i have 15 images of size mxn which has to be converted to 1 x m*n matrix .
then i have to save these in the form of mat file having 15 x m*n matrix. can u
help me to do this in way where i have to call and save using loop because my data
gets increases as it goes on. thanks in advance
Image Analyst
Image Analyst on 12 Apr 2015
Try this:
x1 = x1(:); % Convert to 1-D
x2 = x2(:); % Convert to 1-D
... etc.
x15 = x15(:); % Convert to 1-D
dark = dark(:); % Convert to 1-D
% Now save them all into a single mat file.
save(matFileName, 'x1', 'x2, 'x3', 'x4', ...
'x5', 'x6', 'x7', 'x8', ...
'x9', 'x10', 'x11', 'x12', ...
'x13', 'x14', 'x15', 'dark');

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!