I can´t break the main loop with my code on function file
Mostrar comentarios más antiguos
Hi my program it´s working just fine, but I have little problem... I got a 'main while loop' on my script file, and then i create a function file, and when the function file is executed i can´t break the main loop, i try to use if - break, inside the function file, and it´s not possible, i try to use if - break after i call my function, but breaks somewhere on my code when the function file is executed, so I really don´t know how I will break the main loop with my code on function file.
I create a function files to have less lines of code btw.
%script file
%.....
while true %While Main Loop
if a==1
clc
b= menu('How do you want to insert the experimental points?', ... %Menu presentation b
'Through a file','Manually');
end
if b==1 %Menu operation b 'Through a file'
clc
a_file ()
%.........
%and if i use here break command the program don´t execute as i expect
%function file
function a_file ()
disp('Enter below the name of the Excel file that contains the values you want to download.')
disp('ATTENTION: Do not forget to put the end of the file.')
fi= input('Enter the file name: ','s');
while ~exist(fi,'file')
click
warndlg({'The file name was not found.','Please check that you are in the correct directory.'})
disp('Indicate the name of the excel file that contains the values you want to download.')
disp('Warning: Don't forget to put the end of the file.')
fi= input('Enter the file name: ','s');
end
%........... code
tp= str2double(input('Enter your option: ','s')); %User option regarding menu d
while ((tp~=1) && (tp~=2)) || (isempty(tp) || isnan(tp))
errordlg ({'Incorrect option entry.','Please click Ok and enter the desired option in the Command Window.'})
tp= str2double(input('Enter your option: ','s'));
end
if tp==2
clc
msgbox('The program will continue.')
end
end
end
if tp==1
clc
%i can't use break here
msgbox('End of program.')
end
% .......
%I'm trying to break the main loop that´s on script file when my tp variable it´s equal to 1
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!