MATLAB: Run two loop in different script

codecontrolloop

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 ?????

Best Answer

  • %% 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