How would you create a script that is executed more than once?
Ältere Kommentare anzeigen
My question is how would I go about adding to my script so that there are multiple executions or checks? My script will currently only carry out either the first part of the script, or the second part of the script based on distance taken from a sensor (It will also only take this measurement once), It will then stop.
if any(distance > 0.1) % If measured distance is greater than 0.1m, then..,
writeDigitalPin(a,'D10',1); % power digital pin D10,
else % else, execute the following for loop,
for PauseReverse = 0:0.5 % have 1 cycle only of for loop,
pause(5); % pause for 5 seconds before next step,
writeDigitalPin(a,'D11',1); % power on pin D11,
pause(10); % Keep power on for 10 seconds,
writeDigitalPin(a,'D11',0); %power off pin D11,
end % end the for loop,
end % end the if condition.
Prefferably, the initial if condition would be executed, followed by the script executing itself repeatedly until the measured distance is less than 0.1, where it would then carry out the final for loop and stop the script.
Im sorry if that didn't make much sense and I would be grateful for any responses, thank you.
1 Kommentar
Anthony Coelho
am 30 Apr. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!