run two loop in different script

2 Ansichten (letzte 30 Tage)
mohammed alany
mohammed alany am 8 Mai 2019
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 Kommentare
Walter Roberson
Walter Roberson am 9 Mai 2019
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
mohammed alany am 9 Mai 2019
yas
1- rN values should they become available As soon as possible after they are generated?
2-while loop have to continue calculating till rN > 0.9, then (while loop have to stop to start another condition)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 9 Mai 2019
%% animation part
while( distanceToGoal > goalRadius )
[v, omega] = step(controller, robot.CurrentPose);
drive(robot, v, omega)
robotCurrentLocation = robot.CurrentPose(1:2)
distanceToGoal = norm(robotCurrentLocation - robotGoal);
rN = rand;
disp(['rN = ' num2str(rN)])
if rN > 0.9
break;
end
pause(2);
end
  2 Kommentare
Walter Roberson
Walter Roberson am 9 Mai 2019
In this code, one rN value will be generated for each while loop iteration. This achieves your goal that the while loop continues calculating until an rN > 0.9 is generated.
mohammed alany
mohammed alany am 9 Mai 2019
Many thanks dear

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by