MATLAB App Designer <--> Simulink
조회 수: 3 (최근 30일)
이전 댓글 표시
Good morning,
I am trying to put together a proof of concept app for controlling a Simulink Model with App Designer. I am able to create a base app and very simple model. Simply using a Knob control to change a variable in the model. My callback code is currently:
% App Designer
% ----------------------------------------------
% Value changing function: DecelPedalKnob
function SliderValueChanging2(app, event)
changingValue = event.Value;
% this is where I need to add instruction to assign variable to DecelPedal in the model
end
% ----------------------------------------------
I created a "model based" variable called DecelPedal in Simulink and it is tied to a display block.
I've tried a few things like:
set_param(bdroot,'DecelPedal',changingValue);
With no luck. I am sure it is a very simple process. if somone has experience with this I'd greately appreciate it.
댓글 수: 0
채택된 답변
Fangjun Jiang
2018년 10월 30일
Use the build-in model 'f14' as an example, if you drag in a Knob block and connect it to the Gain block Zw, the changing of the knob position actually changes the value of the variable 'Zw' in the base workspace. You can move the knob, then check the value of Zw in the base workspace to see it changes. You could also change the value of Zw in the base workspace first, then update the model and see the knob position changes.
So the command you need to run is for example as below. You don't change anything regarding the Knob block. Rather, you need to change the variable for which it is connected to.
assignin('base','Zw',55)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!