How do I create an array of scalars?

9 views (last 30 days)
I want to make a list of the major and minor axis of several different functions. I made a loop loop that runs images from 1:10. Given, I can already get the reading of each axis, what is wrote with this code?
for j = 1:10,
...
Major_I(j,1) = regionprops(CC,'MajorAxisLength')
Minor_I(j,1) = regionprops(CC,'MinorAxisLength')
end
This loop only returns: Major_I =
10x1 struct array with fields: MajorAxisLength
Minor_I =
10x1 struct array with fields: MinorAxisLength
  1 Comment
Cynth
Cynth on 30 Aug 2011
My question still hasn't been anwsered yet

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 30 Aug 2011
That is because regionprops() returns a structure. Type Major_I.MajorAxisLength and Minor_I.MinorAxisLength in Command Window should give you the scalar numbers. Some of them may be empty. You can convert them to vector if you want. Something like
a=[Major_I.MajorAxisLength]
b=Minor_I.MinorAxisLength
  4 Comments
Cynth
Cynth on 30 Aug 2011
Yes, it has exactly one object. If I write the following code for one image, it returns a major and minor axis.
regionprops(CC,'MinorAxisLength')
regionprops(CC,'MajorAxisLength')
it returns: MajorAxisLength: 448.0581 and MinorAxisLength: 243.0665
Walter Roberson
Walter Roberson on 30 Aug 2011
What is
class(Major_I)
size(Major_I(1))
after the loop?

Sign in to comment.

More Answers (1)

Cynth
Cynth on 30 Aug 2011
I figured it out. Instead, the following code works. info = regionprops(CC, 'MinorAxisLength','MajorAxisLength'); Major_I(j) = info.MajorAxisLength; Minor_I(j) = info.MinorAxisLength;

Community Treasure Hunt

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

Start Hunting!