Hey,
I have a .mat file with a decent number of images created from the MATLAB app 'Image Labeler' and contains 2 labels. Now when I am trying to read the contents of the .mat file, I get this:
>> data=load('trial.mat')
data =
struct with fields:
labelDefs: [2×3 table]
I don't understand why is it a Struct? When I use size I get:
>> size data.labelDefs(1,1)
ans =
1 19
I understand that this image is a 2D, i.e., Black and White. But is it really checking the size of the image here? I am lost after this point. I tried using the imshow function as well but didn't bring me anything. My eventual goal is to use this .mat file to perform classification operation using deep learning and I can't get this things working.
Any kind of guidance and help is really appreciated.
Sorry if this question has been answered already.
Thank you in advance.

 채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 30일

0 개 추천

load() of a .mat file always gives a struct when assigned to a variable. The struct contains one field for every loaded variable.
size data.labelDefs(1,1)
is the same as
size( 'data.labelDefs(1,1)' )
because of command / function equivalence. You need to invoke
size( data.labelDefs(1,1) )

댓글 수: 3

Lipika Kanojia
Lipika Kanojia 2017년 11월 30일
Okay, understood. Now what I get as an answer is the size of the variable?
I suggest you do
data=load('trial.mat');
labelDefs = data.labelDefs;
Now you can
size(labelDefs)
which would show you the size of the table.
When you try size(labelDefs(1,1)) or size(data.labelDefs(1,1)) then what you are asking for is the size of the sub-table obtained by taking the first row and the first column of the table; the answer to that is always going to be 1 by 1, a table with 1 row and 1 column. size(labelDefs{1,1}) would give you the size of what is stored at the first location. A table is like a cell array that way, that using () indexing gives you a container and {} gives you what is inside the container.
Lipika Kanojia
Lipika Kanojia 2017년 12월 1일
Thanks a lot, Walter. It worked :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

질문:

2017년 11월 30일

댓글:

2017년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by