How to set a Simulink block parameter as a variable and update using Matlab?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Amanda Q
am 16 Aug. 2019
Kommentiert: Amanda Q
am 19 Aug. 2019
Hello,
I'm trying to replicate using Matlab variables for parameters in Simulink blocks, like what was used in the Simulink QPSK example:
![RRC Tx Filter Simulink QPSK Ex.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234199/RRC%20Tx%20Filter%20Simulink%20QPSK%20Ex.jpeg)
I would like to be able to define a variable in Matlab, update it in the Matlab code, and have it update automatically in Simulink (especially with variables that are mathematical expressions). The QPSK example source code seems to show this here (my assumption is that Simulink is grabbing the parameter values from this code):
![QPSK Tx code ex.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234200/QPSK%20Tx%20code%20ex.jpeg)
When I tried to do this myself, I had to manually update the parameters in the Model Explorer in order for it to change in Simulink. I've looked around at a lot of documentation (here, here, here & here for example) and past questions (here), but I'm not seeing the exact answer. It may be a more complicated solution than I anticipated, but I was hoping to keep my Simulink models simple and easy to update. (I'm still learning the intricacies of Simulink and Matlab right now.)
My basic transmitter and Matlab code is shown below for reference. The Matlab file I created (qpsktxinit) is currently located in the model workspace, and is a 1x1 struct with 10 variables.
I appreciate any help/direction you can offer for this issue.
Regards,
Amanda
![QPSK TX Simulink.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234201/QPSK%20TX%20Simulink.jpeg)
![Rand_Int.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234202/Rand_Int.jpeg)
![RRC filter.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234203/RRC%20filter.jpeg)
![QPSK TX Init code.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/234204/QPSK%20TX%20Init%20code.jpeg)
0 Kommentare
Akzeptierte Antwort
Archit Dhanani
am 16 Aug. 2019
You could use a model callback in this case if you have not already tried this:
Also, you can take a look at this:https://www.mathworks.com/help/simulink/ug/model-callbacks.html
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Event Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!