필터 지우기
필터 지우기

how get value from edit textbox gui matlab

조회 수: 24 (최근 30일)
Unkown
Unkown 2021년 4월 8일
댓글: DGM 2021년 4월 8일
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