display the result in EDIT TEXT

hi there, i tried to open an image in GUI , and do some image processing, the result will be show in command window. how can i show the result 'area' in edit text?

... get an image ... image processing

if ~isempty(regexpi(filetext, expr1)) && ~isempty(regexpi(filetext, expr2))
    disp('Area');
end

... call back code

function edit2_Callback(hObject, eventdata, handles)
set(handles.edit2,'string',disp)

but its not showing the 'area' in edit text yet.

6 comentarios

Geoff Hayes
Geoff Hayes el 28 de Jun. de 2018
narges - what result is showing in the command window? The image (which, from the code, should appear in the handles.asxes2) or do you mean the "Area"? Please clarify.
narges
narges el 28 de Jun. de 2018
Editada: narges el 28 de Jun. de 2018
'area' the 'area' will extract from image and I try to show it in pannel
Geoff Hayes
Geoff Hayes el 28 de Jun. de 2018
Where in the GUI do you want to show this? Do you have a text or edit text field/control to display this?
narges
narges el 28 de Jun. de 2018
can i show it in pannel? or do i need edit text?
Geoff Hayes
Geoff Hayes el 28 de Jun. de 2018
You need a text or edit text control. Presumably you are creating a multi-line string so you will want to build the string and then set it in the text control.
narges
narges el 28 de Jun. de 2018
thanks for your answer, how should I pass disp('Area') in edit text?

Iniciar sesión para comentar.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 28 de Jun. de 2018
narges - if you wish to write 'Area' in your text control, you would do something like
set(handles.text1, 'String', 'Area');
(assuming that handles.text1 is the handle to the text control that you wish to write to).

2 comentarios

narges
narges el 28 de Jun. de 2018
thank you Geoff,
actually the result on text control should be different based on the input
for example if we have area in image... disp 'area'
if we have cable in image... disp 'cable'
if ~isempty(regexpi(filetext, expr1)) && ~isempty(regexpi(filetext, expr2))
disp('Area');
end
if ~isempty(regexpi(filetext, expr3)) && ~isempty(regexpi(filetext, e
xpr4))
disp('Cable');
end
i put below codes in call back but still it is not work
function edit2_Callback(hObject, eventdata, handles)
set(handles.edit2,'string',disp)
thanks for your help
No variable named disp is defined in your callback, so in that context, your set() line is equivalent to
set(handles.edit2,'string',disp())
where disp() is a request to display nothing.
There is no good way to say "retrieve the last thing that was displayed in the command window"
You should be setting a shared variable in your other function instead of using disp(), and you would retrieve that variable in the callback.
Note, though, that edit2_Callback would not be called unless you interacted with the edit2 box in some way, such as by entering text there (and then pressing return), or by clicking on it and then clicking on something else.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Jun. de 2018

Comentada:

el 28 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by