plotting '.mat' ' .dat' files extension

조회 수: 6 (최근 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 CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by