Tell the user something is wrong
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Inês
am 10 Jan. 2022
Beantwortet: Image Analyst
am 11 Jan. 2022
I have to ask the user to input some data so then I can show to him the image’s referring to the data he gave me however how can I write a script where I tell the user that the data he gave doesn’t exist in the images I have in my possession without appearing the error message from matlab. I think I made the question a little confusing but I hope someone understands and help me because it’s very important. Thank you!
0 Kommentare
Akzeptierte Antwort
yanqi liu
am 11 Jan. 2022
yes,sir,if check the file is or not exist,may be use
if ~exist(your_file_path, 'dir')
error('not exist');
end
0 Kommentare
Weitere Antworten (2)
Jon
am 10 Jan. 2022
Bearbeitet: Jon
am 10 Jan. 2022
If I understand your question, I think that you may find that you can use MATLAB's errordlg function can do what you are looking for. https://www.mathworks.com/help/matlab/ref/errordlg.html
0 Kommentare
Image Analyst
am 11 Jan. 2022
To check if a folder exists, where folder is your variable name, and alert the user if the folder does not exist, use isfolder():
if ~isfolder(folder)
errorMessage = sprintf('Error: folder does not exist:\n%s', folder);
uiwait(errordlg(errorMessage));
return;
end
To check if a file does not exist and alert the user if the file does not exist, use isfile():
if ~isfile(fullFileName)
errorMessage = sprintf('Error: file does not exist:\n%s', fullFileName);
uiwait(errordlg(errorMessage));
return;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu File Operations 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!