To store elements with different datatypes from loop

1 view (last 30 days)
Hello my seniors, Could you please help me because I have faced some problems to store elements with different data types.I want to store double array ,structure array that I calculated from loop . How can I store these heterogeneous data types . Thanks all ......

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 18 Apr 2016
Use cell arrays
M{1}=[1 2 3];
M{2}=5
M{3}='text'
  2 Comments
Khaing Zin Htwe
Khaing Zin Htwe on 20 Apr 2016
Thanks a lot for your kind answer,sir.I wrote that code below,but I got only results for the first iteration,not the second.Why please?Here, Nnodule is 2.
if true
% if Nnodule>=1
for i=1:Nnodule
if Nnodule==1
DetectNodule=Nodule;
else if Nnodule>1
if i==1
DetectNodule=NoduleOne;
else if i==2
DetectNodule=NoduleTwo;
else disp('No');
end
end
else disp('No');
end
end
figure,imshow(DetectNodule);
stats=regionprops(DetectNodule,'Area','ConvexArea','Eccentricity','EquivDiameter','Perimeter','Solidity');
allArea=stats.Area;
ConvexA=stats.ConvexArea;
Eccen=stats.Eccentricity;
Diameter=stats.EquivDiameter;
Perimeter=stats.Perimeter;
soli=stats.Solidity;
Roundness=4*pi*allArea/Perimeter^2; Skew=skewness(DetectNodule); Kur=kurtosis(DetectNodule); Variance=var(DetectNodule); Standard=std(DetectNodule); Smoothness=1-1./(1+uint8(Standard)); end i=i+1; end end
Khaing Zin Htwe
Khaing Zin Htwe on 20 Apr 2016
Thanks , I did it right now,sir. I used the whole image that includes all objects,2 objects here,not used DetectNodule in regionprops .If that line is okay, the later lines are all okay.now i got results for both objects.Thanks sir.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!