problem in assigning elements

hi, i'm developing a program to measure pupil diameter changes due to a light stimulus.
this is a part of my mfile
clear
video=input('insert video:');
v=aviread(video);
info=aviinfo(video);
n=info.NumFrames;
w=info.Width;
h=info.Height;
t=info.FramesPerSecond;
for a=1:n
p=v(a).cdata<19000;
p1=bwlabel(p);
stats(a) = regionprops(p1,'EquivDiameter');
end
my program works in this way: 1.acquire video 2.read the video frames 3.locate and calculate the pupil diameter(using the regionprops function)
but the problem is, sometimes a frame can yield more than one diameter value, which return error at the command "stats(a) = regionprops(p1,'EquivDiameter');"
here is the error message:
??? In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in ==> pupil at 15 stats(a) = regionprops(p1,'EquivDiameter');
what i interpret from this error line is, my "stats(a)" variable can only contain 1 value of the "regionprops(p1,'EquivDiameter');" variable
What should i do to make my "stats(a)" variable able to contain more than 1 value from my "regionprops(p1,'EquivDiameter');" variable
Can anyone give me a clue / solution regarding this problem?

回答 (1 件)

Sean de Wolski
Sean de Wolski 2011 年 7 月 20 日

1 投票

Define stats as a cell array
stats = cell(n,1);
for ii = 1:n
%do stuff
stats{ii} = regionprops(stuff)
end

この質問は閉じられています。

質問済み:

2011 年 7 月 20 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by