run two loop in different script
이전 댓글 표시
i am running a loop in the first script, and in the second script there is loop generate random number "rN".
and there is a condition in the first script says:
if rN > 0.9
c=('stop')
end
how i can combine these two script ?????
댓글 수: 7
James Tursa
2019년 5월 8일
Please show your two scripts, or at least enough of a subset of them, to give us more detail.
gonzalo Mier
2019년 5월 8일
Always in this cases is a good practice to show a full example of what you are doing. Do you have any reason for not doing the second script a function that it's called by the first one? The function of the second script can return rN and do your math with that
mohammed alany
2019년 5월 8일
Walter Roberson
2019년 5월 8일
%% animation part
while( distanceToGoal > goalRadius )
[v, omega] = step(controller, robot.CurrentPose);
drive(robot, v, omega)
robotCurrentLocation = robot.CurrentPose(1:2)
distanceToGoal = norm(robotCurrentLocation - robotGoal);
for i = 1 : 5
rN(i) = rand;
pause(2);
disp(['rN = ' num2str(rN)])
end
if any(rN > 0.9)
c = 'stop';
%did you want to break out of the while loop here?
end
end
mohammed alany
2019년 5월 8일
Walter Roberson
2019년 5월 9일
As rN values are generated, at what point should they become available to the other loop? As soon as possible after they are generated? After the 2 second pause? After the 'disp' ?
Should each iteration of the while loop be given the 5 random numbers, or should each iteration be given one random number? Should the 2 second pause affect the while loop?
mohammed alany
2019년 5월 9일
채택된 답변
추가 답변 (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!