Need help with getting a function to SIMULINK

1 view (last 30 days)
Hello, I am producing a FM Signal using the following message signal
fs=1000;
t = 0:1/fs:2;
m =@(t) -sawtooth(2*pi*(t+0.5)) ;
I want to input this m function as it is to SIMULINK using simin block to repeat the same modulation process but with blocks. Sorry for it's a silly question, but im still new with SIMULINK. Thanks in advance

Accepted Answer

Bhavana Sapparapu
Bhavana Sapparapu on 3 Nov 2022
Hi Abdelrhman Abdelfatah,
I understand that you want to create a Simulink source block that can generate an FM signal using the "m" function that you have provided. This is same as loading a "timeseries" data generated using the "m" function into the Simulink model using a "From Workspace" (simin) block.
The following documentation provides an example as to how to load timeseries data using the "simin" block in a Simulink model:
More specifically, look at the "Load timeseries Data" section in the documentation:
As shown in the example, you can do the following in your Simulink file:
  • Create a "Callback Button" block, populate the "ClickFcn" with the following code and click on the button (or) go to Model Settings > Model Properties > Callbacks and populate the "InitFcn" with the following code:
fs = 1000;
t = 0:1/fs:2;
m = @(t)-sawtooth(2*pi*(t+0.5));
d = m(t);
simin = timeseries(d,t);
  • Add a "From Workspace" (simin) block to your Simulink model.
  • Connect it to a "Scope" block or an "Out" block to view the results.
  • Change the simulation "Stop Time" to 2.0s (since your upper bound for t is 2).
  • Update the model and run.
The result would look like something as follows:

More Answers (0)

Categories

Find more on Event Functions in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!