Passing slider value to the simulink model

Hello, I am trying to pass / control values from a slider using GUIDE to simulink model as one of the inputs. However not able to do so as not getting the work around for using set_param. Could someone help me with the steps. I am new to the programming world so your guidance and help will be really appreciated.

답변 (2개)

Sebastian Castro
Sebastian Castro 2015년 4월 13일

0 개 추천

If your block is currently selected, you can use gcb to get the block's name.
>> get_param(gcb,'gain')
>> set_param(gcb,'gain','5')
If already know the name of the block, just replace gcb with the actual name -- for example, 'myModel/Slider Gain'.
- Sebastian
Aasif Shaikh
Aasif Shaikh 2015년 4월 13일

0 개 추천

Hi Sebastian, thanks for your reply. So what is gain here ? is it the signal name in simulink model. And where does the value '5' come from ? I want to send the values from the slider to the model.
Thanks

댓글 수: 4

First of all: Please respond to answers with comments. Otherwise, the conversation can get out of order depending on the number of votes, etc.
Sorry, I somehow read that you wanted to interact between GUIDE and a Slider Gain block. What exactly are you looking to do -- change a slider value in GUIDE and then pass that constant value to a block in Simulink? If so, which block(s)?
Aasif Shaikh
Aasif Shaikh 2015년 4월 14일
I am trying to create a GUI (using GUIDE) which has a slider. Now I want to use this slider as an input to one of the signals / variables in simulink model. So whatever value I change in the GUI the same should be passed onto the simulink variable.
Thanks
Aasif Shaikh
Aasif Shaikh 2015년 4월 14일
Just to add, need to pass that value to a constant block in the simulink model.
OK, so it should be (for example):
blockName = 'myModel/Constant';
x = 14;
set_param(blockName,'Value',num2str(x));
- Sebastian

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2015년 4월 13일

댓글:

2015년 4월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by