[SOLVED] Using global flags to advance in a script

Hello fellow community
I want to make a script with converting it into a GUI in the future in mind. It's purpose is to run parts of an algorithm one after another when i want to. Here I've submitted simplified version to replicate my problem. I'll be extremelly thankful if you can help me.
global locate_Flag;
global aim_Flag;
global throw_Flag;
locate_Flag = 0;
aim_Flag = 0;
throw_Flag = 0;
if locate_Flag == 1
disp('located succesfully');
if aim_Flag == 1
disp('aimed succesfully');
if throw_Flag == 1
disp('threw succesfully');
else
throw_Flag_temp = num2str(throw_Flag);
input(throw_Flag_temp);
str2double(throw_Flag_temp)
throw_Flag = throw_Flag_temp;
end
else
aim_Flag_temp = num2str(aim_Flag);
input(aim_Flag_temp);
str2double(aim_Flag_temp)
aim_Flag = aim_Flag_temp;
end
else
locate_Flag_temp = num2str(locate_Flag);
input(locate_Flag_temp);
str2double(locate_Flag_temp)
locate_Flag = locate_Flag_temp;
end

 채택된 답변

JV
JV 2021년 1월 6일

0 개 추천

Ok so I propably managed to solve this myself
global locate_Flag;
global aim_Flag;
global throw_Flag;
while(1)
locate_Flag = 0;
aim_Flag = 0;
throw_Flag = 0;
locate_Flag_temp = input('waiting for confirmation ');
locate_Flag = locate_Flag_temp;
clear locate_Flag_temp
if locate_Flag == 1
disp('located succesfully');
aim_Flag_temp = input('waiting for confirmation ');
aim_Flag = aim_Flag_temp;
clear aim_Flag_temp
if aim_Flag == 1
disp('aimed succesfully');
throw_Flag_temp = input('waiting for confirmation ');
throw_Flag = throw_Flag_temp;
clear throw_Flag_temp
if throw_Flag == 1
disp('threw succesfully');
end
end
end
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

태그

질문:

JV
2021년 1월 6일

편집:

JV
2021년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by