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
2015년 4월 13일
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
2015년 4월 13일
0 개 추천
댓글 수: 4
Sebastian Castro
2015년 4월 13일
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
2015년 4월 14일
Aasif Shaikh
2015년 4월 14일
Sebastian Castro
2015년 4월 14일
OK, so it should be (for example):
blockName = 'myModel/Constant';
x = 14;
set_param(blockName,'Value',num2str(x));
- Sebastian
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!