필터 지우기
필터 지우기

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

조회 수: 5 (최근 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에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by