How to modify variables during Simulink simulation
조회 수: 24 (최근 30일)
이전 댓글 표시
Hi everyone, I am quite new to MATLAB and Simulink.
I am developing an high level simulation of a PLL and the input signal is being simulated with a sawtooth voltage source (pulse voltage control where the rise time and fall time are identical and the hold time is infinitely smaller than the latters) which is used as base signal for a PWM of a square wave (based on the sawtooth values, the duty cycle of the PWM changes).
I need to change the frequency of this sawtooth at a certain point during the simulation to measure how fast the PLL settles to the new frequency value.
The ideal way would be to change the frequency parameter in the model workspace during simulation, but this would mean that I need to generate the signal using a MATLAB Function Block (plus, I don't know why, but assignin doesn't allow me to change the model workspace when I put caller instead of base: the output says "For C/C++ code generation, the value of input workspace must be 'base'.").
I tried to do so, but multiple errors occur (e.g. the square pulse duration is not what the duty cycle should impose). You can try yourself to substitute the Frequency Changer block in the first implementation (pulse voltage source) with the constant square_freq and see how the pulses are 50ps shorter.
I attached the model for the generation and the base workspace that makes it work.
댓글 수: 0
답변 (1개)
Leepakshi
2025년 11월 20일 5:15
Hi Tommaso,
The error you are encountering in MATLAB regarding the square pulse duration not matching the duty cycle is likely due to incorrect settings or parameters in your duty cycle calculation.
Refer to this Mathworks documentation for dutycycle:
For assignin issue, assignin('caller',...) does not work inside MATLAB Function Blocks for code generation because the workspace must be base.
Refer to this Mathworks documentation for assignin:
If this doesn't solve the issue, you can contact Mathworks Support using below link:
Hope it helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!