Convert for loop with cells and polyarea into a cellfun function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alejandro Fernández
le 31 Jan 2021
Commenté : Alejandro Fernández
le 31 Jan 2021
Hi, I was wondering if it would be possible to convert those lines of code of the for loop into the same expression but using the function cellfun
for i = 1 : length(dataOUT)
area(i,1) = polyarea(dataOUT{i}(:,1),dataOUT{i}(:,2));
end
[~,idx_cluster] = max(area);
Just for this example, dataOUT could be:
p = linspace(0,2.*pi,9);
x = 1.2*cos(p)';
y = 1.2*sin(p)';
dataOUT{1}(:,1) = x;
dataOUT{1}(:,2) = y;
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!