Borrar filtros
Borrar filtros

How to fix this error?

1 visualización (últimos 30 días)
wyeen chow
wyeen chow el 16 de Dic. de 2020
Editada: Cris LaPierre el 16 de Dic. de 2020
Hi, I had facing this problem. I try to compute the GUI and it comes out this error.

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Dic. de 2020
fm is not a simple one line edit text box like you thought. In guide, you had two lines for it, so the get() call returns a cell array instead of a character array. Here, get your values in the run callback like below. I'm also attaching a fixed version of your program.
% Get the contents of the edit fields.
editFieldContents = handles.fm.String;
if isempty(editFieldContents)
warningMessage = sprintf('fm is empty. Please enter a value for it');
uiwait(warndlg(warningMessage));
return;
end
val1 = str2double(editFieldContents);
editFieldContents = handles.fc.String;
if isempty(editFieldContents)
warningMessage = sprintf('fc is empty. Please enter a value for it');
uiwait(warndlg(warningMessage));
return;
end
val2 = str2double(editFieldContents);
editFieldContents = handles.EM.String;
if isempty(editFieldContents)
warningMessage = sprintf('EM is empty. Please enter a value for it');
uiwait(warndlg(warningMessage));
return;
end
val3 = str2double(editFieldContents);
editFieldContents = handles.EC.String;
if isempty(editFieldContents)
warningMessage = sprintf('EC is empty. Please enter a value for it');
uiwait(warndlg(warningMessage));
return;
end
val4 = str2double(editFieldContents);
editFieldContents = handles.RESIS.String;
if isempty(editFieldContents)
warningMessage = sprintf('RESISTANCE is empty. Please enter a value for it');
uiwait(warndlg(warningMessage));
return;
end
val5 = str2double(editFieldContents);
  1 comentario
wyeen chow
wyeen chow el 16 de Dic. de 2020
Thank you sir ! It works.

Iniciar sesión para comentar.

Más respuestas (2)

KSSV
KSSV el 16 de Dic. de 2020
If you want to open .fig file.
openfig('DSBSCfig.fig')
If you want to run the .m file, open it and press F5 or press the run button. Or you be in the directory where the DBSCfig.m file is present and type
DBSCfig
  1 comentario
wyeen chow
wyeen chow el 16 de Dic. de 2020
I see. Thank you sir!

Iniciar sesión para comentar.


Cris LaPierre
Cris LaPierre el 16 de Dic. de 2020
Editada: Cris LaPierre el 16 de Dic. de 2020
In checking your gui, the issue is you have given both the label and the edit field the same tag (fm for example). So when you run the command get(handles.fm,'String'), you get the string property of both objects.
K>> get(handles.fm,'String')
ans =
2×1 cell array
{'"0"' }
{'Frequency Modulate(fc)'}
I suggest updating your tags so that no two objects use the same tag.
  1 comentario
Image Analyst
Image Analyst el 16 de Dic. de 2020
For robustness, you might assume that if it's a cell array, to get the first (or last) entry:
editFieldContents = handles.fm.String;
if iscell(editFieldContents)
% Extract first string.
editFieldContents = editFieldContents{1}; % or editFieldContents{end}; depending on what you want.
% Put that one string back into the edit field.
handles.fm.String = handles.fm.String;
end

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by