plotting '.mat' ' .dat' files extension

2 views (last 30 days)
Hello,
I have a folder that contains .mat subfolders every subfolder is a struct array ,the first struct contains 3 fields one called props <668x1026 logical> , the second called boxes <668x4 int32> and third one called superpixels <500x411 int16>, and this same issue with .dat files, how can I generate an image from these arrays. THanks for your attention and help
  1 Comment
Houayda Gharbi
Houayda Gharbi on 4 Sep 2015
Edited: Walter Roberson on 4 Sep 2015
Hello, thank u for your help ,accually i tried this code ,i obteined this erreur
imagesc( repmat(double(props),1,1,3) ); Error using ==> repmat Too many input arguments
so i changed it into imagesc(props) ih had this figure

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 4 Sep 2015
.dat files do not have fields, so we cannot simply pull data out of them. We could pull data out if we knew the exact binary structure. For example even if the data is just dumped using exactly the datatypes you list, we would need to know if the entries have size information stored and we would need to know whether the entries are stored "across" the rows (common) or "down" the columns (which MATLAB does.)
projectdir = 'C:\full\name\of\your\main\folder';
dinfo = dir( fullfile(projectdir, '*.mat'));
numfile = length(dinfo);
for K = 1 : numfile
%load a .mat file
thisfile = fullfile( projectdir, dinfo(K).name );
data = load(thisfile);
%guess that the struct is in the first variable we find.
%it sure would be easier if we knew the name of the structure....
datavars = fieldnames(data);
varname = datavars{1};
%extract the data we loaded
props = data.(varname).props;
boxes = data.(varname).boxes;
superpixels = data.(varname).superpixels;
%now draw it.
%it sure would be easier if we knew what the relationship was
%between the structure fields. Guess we'll just make images of each of them.
figure
subplot(3,1,1);
imagesc( repmat(double(props),1,1,3) );
xlabel('props');
title(thisfile);
subplot(3,1,2);
imagesc( boxes );
colormap(jet(256));
xlabel('boxes');
title(thisfile);
subplot(3,1,3);
imagesc( superpixels );
colormap(jet(256));
xlabel('superpixels');
title(thisfile);
end
  2 Comments
Houayda Gharbi
Houayda Gharbi on 4 Sep 2015
Hello, thank u for your help ,accually i tried this code ,i obteined this erreur imagesc( repmat(double(props),1,1,3) ); Error using ==> repmat Too many input arguments. so i changed it into imagesc(props) ih had this figure
Walter Roberson
Walter Roberson on 4 Sep 2015
Try
repmat(double(props),[1,1,3]) );
Perhaps you are using a relatively old version of MATLAB?

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps 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!