how to use multiple 'for loop' for one function?
古いコメントを表示
intersection_point = [];
for i = 1:length(mean_trajectory_double)-1
for j = 1:length(RKSI_Arr_33R)
for k = 1:length(RKSI_Arr_33R.Latitude)
[I,check]=plane_line_intersect([mean_trajectory_double(i+1,1) mean_trajectory_double(i+1,2) NormalVectorsmean_trajectory_double(i+1,3)]...
,[mean_trajectory_double(i+1,1) mean_trajectory_double(i+1,2) mean_trajectory_double(i+1,3)]...
,[RKSI_Arr_33R(j).Longitude(k) RKSI_Arr_33R(j).Latitude(k) RKSI_Arr_33R(j).BAlt(k)]...
,[RKSI_Arr_33R(j).Longitude(k+1) RKSI_Arr_33R(j).Latitude(k+1) RKSI_Arr_33R(j).BAlt(k+1)]);
intersection_point = [intersection_point; ];
end
end
end
%% [I,check]=plane_line_intersect(n,V0,P0,P1)
I need to use multiple for loop for one function. I have used multiple for loop, but i have not used multiple for loop for one function.
this function need 4 input and 2 output(I,check). I is intersection_point and check is an indicator.
for more information about this function, https://kr.mathworks.com/matlabcentral/fileexchange/17751-straight-line-and-plane-intersection
What i want to do is that
when i is 1, j is 1 and k(1~100) is finished, it goes to i(1), j(2),k(1~100).
and j(1-200) is finisiehd, it goes to i(2),j(1),k(1~100) and i(2),j(2),k(1~100) like this.
if you need more clarification to answer my question, just tell me
Thanks.
7 件のコメント
Rik
2022 年 6 月 24 日
Your loop will do as you describe. However, you're overwriting the I and check variables every iteration, without storing them anywhere.
Sierra
2022 年 6 月 24 日
Kenneth Joseph Paul
2022 年 6 月 24 日
編集済み: Kenneth Joseph Paul
2022 年 6 月 24 日
For storing the intersection point you need to do this
intersection_point = [intersection_point; I ];
Kenneth Joseph Paul
2022 年 6 月 24 日
Put a break point at
[I,check]=plane_line_intersect([mean_trajectory_double(i+1,1) mean_trajectory_......
And print each of the inputs to the function and make sure that the dimensions are right
Sierra
2022 年 6 月 24 日
Jan
2022 年 6 月 24 日
Kenneth means a "break point". Click in the bar on the left side in the editor. Then a red dot appears. Matlab stops at this point and you can check the varaibels used in this line.
The break command is something else.
Kenneth Joseph Paul
2022 年 6 月 24 日
You need to use a "break point". As you said a "break" teminates the loop. A "break point" is used to temporarily pause the execution of the code. You can follow the page linked below, if you are not familiar with "breakpoint"
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!