plotting '.mat' ' .dat' files extension

9 ビュー (過去 30 日間)
Houayda Gharbi
Houayda Gharbi 2015 年 9 月 3 日
コメント済み: Walter Roberson 2015 年 9 月 4 日
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 件のコメント
Houayda Gharbi
Houayda Gharbi 2015 年 9 月 4 日
編集済み: Walter Roberson 2015 年 9 月 4 日
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 2015 年 9 月 4 日
.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 件のコメント
Houayda Gharbi
Houayda Gharbi 2015 年 9 月 4 日
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 2015 年 9 月 4 日
Try
repmat(double(props),[1,1,3]) );
Perhaps you are using a relatively old version of MATLAB?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by