error message for wrong data loaded
Mostrar comentarios más antiguos
Hi everybody,
In my GUI I´m loading data and storing them into variables X and y. The a value is entered by user.It looks like that:
[FILENAME,PATHNAME]=uigetfile('*.txt')
loaddata=load(FILENAME)
if (a==1)
X = loaddata(:,1)
y = loaddata(:,2)
end
if (a==2)
X = loaddata(:,1:2)
y = loaddata(:,3)
end
...
But I would like to add an error message in case that user load the wrong data set if he set the value a is equal for example to 1. Do you guys have any idea ? TY for help
Respuestas (1)
Walter Roberson
el 14 de Mayo de 2013
0 votos
See error() and warning() and warndlg() and disp() and fprintf()
7 comentarios
Lenka Misenkova
el 15 de Mayo de 2013
Editada: Lenka Misenkova
el 15 de Mayo de 2013
Valmir Sadiku
el 15 de Mayo de 2013
whence comes the 'a'? Is it user input data? You have to put more effort to get an answer.
Valmir Sadiku
el 15 de Mayo de 2013
Sorry, my mistake.
If 'a' is an input data then you can simply do it in this way:
if( a == 1)
% load data set 1
elseif (a == 2)
% load data set 2
elseif (a == x)
% load data set x
else % wrong input from the user
% print error message
end
regards V.Sadiku
Lenka Misenkova
el 15 de Mayo de 2013
Walter Roberson
el 19 de Mayo de 2013
if ndim(loaddata) ~= 2 | size(loaddata,2) ~= 3
Lenka Misenkova
el 20 de Mayo de 2013
Walter Roberson
el 20 de Mayo de 2013
If your difficulty is solved, please mark this Answer as Accepted.
Categorías
Más información sobre Programming 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!