Repeating a function for different values and storing the output in different variables.

15 次查看(过去 30 天)
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

采纳的回答

David Hill
David Hill 2021-4-2
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by