how get value from edit textbox gui matlab

48 次查看(过去 30 天)
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.

回答(1 个)

DGM
DGM 2021-4-8
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 个评论
Unkown
Unkown 2021-4-8
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 2021-4-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by