Question
I want to save the eccentricity and metric values of many images so that they form a table of eccentricity values and a metric of multiple images. How do i make a loop? source code: clear; clc; close all; %mfolder='E:\Kuliah\TesMatlalb\tesLATIH'; %filenames = dir(fullfile(mfolder, '*.png')); %total = numel(filenames); i = imread('21.png'); im = im2bw(i,.25); bw = imcomplement(im); bw = imfill(bw,'holes'); bw = bwareaopen(bw,50); %figure,imshow(bw); [bw,num] = bwlabel(bw); bbox = zeros(num,4); RGB4 = i; for k = 1:num bw2 = bw==k; [B,L] = bwboundaries(bw2,'noholes'); stats = regionprops(L,'All'); perimeter = cat(1,stats.Perimeter); area = cat(1,stats.Area); eccentricity = cat(1,stats.Eccentricity); metric = 4*pi*area/perimeter^2; bbox(k,:) = cat(1,stats.BoundingBox); end RGB5 = insertShape(i, 'Rectangle', bbox, 'LineWidth', 1); figure, imshow(RGB5);
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 25, 2026
Index your variables with k:
area(k) = cat(1,stats.Area);
eccentricity(k) = cat(1,stats.Eccentricity);
metric(k) = 4*pi*area/perimeter^2;
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →