필터 지우기
필터 지우기

Loop function in Matlab Programming

조회 수: 4 (최근 30일)
NGOC TAM LAM
NGOC TAM LAM 2019년 10월 14일
댓글: NGOC TAM LAM 2019년 10월 14일
Hello all, I am trying to make a loop as below description in Matlab programming. It likes two trees exploration.
Problem1:
I create a function with two input variables and output with four vars.
From originCoord(x,y) it creates two new coordinates R(x,y), L(x,y); (R means Right, L: left)
next R(x,y) -> new R1(x1,y1) & L1(x1,y1) and L(x,y) -> new L2(x2,y2) & R2(x2,y2)
then to be continued .....
loop will stop when one of the newCcoordinates() == targetCoordinates(xtarget, ytarget).
[R1,L1] = doRightRunning(x,y);
[L2,R2] = doLeftRunning(x,y);
[R3,L3] = doRightRunning(R1_x,R1_y);
[R4,L4] = doRightRunning(L1_x,L1_y);
[R5,L5] = doLeftRunning(R2_x,R2_y);
[R6,L6] = doLeftRunning(L2_x,L2_y);
....
I got stuck when the output always greater than input. I cannot use all the output for the next loop.
Please help me to comment on how to make a loop for this case. Thanks.
Problem2: when one of the newCcoordinates() == targetCoordinates(xtarget, ytarget), how can I know which varibales in which direction from origin loop to last loop generating the result? (like which brands of the tree achieving the target). In C++, I can use stack to save but in Matlab I do not know how can I save the variable for each loop.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by