how get value from edit textbox gui matlab

15 visualizaciones (últimos 30 días)
Unkown
Unkown el 8 de Abr. de 2021
Comentada: DGM el 8 de Abr. de 2021
hello,
How can i get value from another edit textbox and use this value again to perform some calculation.
For example, this value is obtain from the graph
set(handles.kp,'String',num2str(sysP1D.Kp));
i want to use this value to perform another calculation.

Respuestas (1)

DGM
DGM el 8 de Abr. de 2021
If you know what editbox you're looking for in your handles object, you can just get its contents
myvariable=get(handles.myeditbox,'String');
If you you need numeric output, obviously use str2num() on it.
  2 comentarios
Unkown
Unkown el 8 de Abr. de 2021
k = set(handles.edit_kp,'String',num2str(sysP1D.Kp));
tau = set(handles.edit_tp1,'String',num2str(sysP1D.Tp1));
d = set(handles.edit_thetap,'String',num2str(sysP1D.Td));
s = tf('s');
K1 = k; D1 = d; tau1 = tau;
G = K1*exp(-D1*s)/(tau1*s+1);
KP = num2str(get(handles.K,'String'));
KI = num2str(get(handles.I,'String'));
KD = num2str(get(handles.D,'String'));
set_param('block/Gs','Denominator',get(handles.K1,'string'));
set_param('block/Gs','Numerator',get(handles.tau1,'string'));
sim('block');
however, after i did this. the value in the simulink doesnt change.
DGM
DGM el 8 de Abr. de 2021
Oh, you're trying to set simulink block parameters? I don't see that there's any obvious problem with the code you've shown, but I imagine that's not the entire story. If you've verified that the values you are getting from your edit box are being recieved and stored correctly in the intended variables, then I'd suggest you make a new question that specifically addresses the issue of getting simulink block parameters to update after being set programmatically.
It's been nearly 10 years since I did this sort of thing with simulink, and I imagine many things, including recommended practices, have changed.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by