how to use multiple 'for loop' for one function?
Mostra commenti meno recenti
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 Commenti
Rik
il 24 Giu 2022
Your loop will do as you describe. However, you're overwriting the I and check variables every iteration, without storing them anywhere.
Sierra
il 24 Giu 2022
Kenneth Joseph Paul
il 24 Giu 2022
Modificato: Kenneth Joseph Paul
il 24 Giu 2022
For storing the intersection point you need to do this
intersection_point = [intersection_point; I ];
Kenneth Joseph Paul
il 24 Giu 2022
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
il 24 Giu 2022
Jan
il 24 Giu 2022
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
il 24 Giu 2022
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"
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!