Passing slider value to the simulink model
Mostrar comentarios más antiguos
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.
Respuestas (2)
Sebastian Castro
el 13 de Abr. de 2015
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
el 13 de Abr. de 2015
0 votos
4 comentarios
Sebastian Castro
el 13 de Abr. de 2015
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
el 14 de Abr. de 2015
Aasif Shaikh
el 14 de Abr. de 2015
Sebastian Castro
el 14 de Abr. de 2015
OK, so it should be (for example):
blockName = 'myModel/Constant';
x = 14;
set_param(blockName,'Value',num2str(x));
- Sebastian
Categorías
Más información sobre Event Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!