Repeating a function for different values and storing the output in different variables.
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I was wondering if anyone could help me out - I have a subfunction that creates a plane through my 3D model based on 3 points (p0 p1 and p2) and finds the points from the model point cloud on this plane. My output at the end is P, a matrix n x 3 that contains the coordinates for all points on the plane. The function itself works perfectly.
However, would like to rerun that subfunction multiple times for different p0, p1, p2 configurations and store the output for each iteration seperately in P1 P2 P3 etc.
How do I do this?
Thanks!
function points_on_plane
p0 = [ x y z]
p1 = [ x y z]
p2 = [ x y z]
% followed by rest of the function for creating plane and finding points on the plane
% ind - indexes points from x y and z coordinate arrays that are closest to
% the plane
P=[xcoord(ind),ycoord(ind),zcoord(ind)];
end
2 commentaires
Stephen23
le 2 Avr 2021
"Repeating a function for different values and storing the output in different variables."
Use indexing:
Réponse acceptée
David Hill
le 2 Avr 2021
for k=1:10%however many times you want to run it
P{k}=points_on_plane(p0,p1,p2);%just use a cell array for your output so that you can index into it
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures 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!