Simulink - Multiplication of Two Sine Signals (i couldn't understand the logic)

13 views (last 30 days)
Hi, while I was doing some practises on Simulink to learn it better on my own, I have stuck and could not find the reason behind one of my self questions:
You can right click and download the pictures for a closer look...
Here, first I have created two sine wave and multiplied them with the "product block".
(I adjusted samples per frame for sine waves as "5" for both of them.)
After that here is the sine signal parameters:
Here is the output:
My question is,
How does the value of the signal dimension ( [5x1] ) was created?
I mean which parameter for sine wave dis affect that dimension?
and my second curiosity is,
When change the value “samples per frame” of the one of sine waves, (I adjusted one of them 1 and other one is 5) the output signal has been changed just like that below:
I could not understand that, when I change one the samples per frame as "1" and other one as "5", its period has been changed. However I could not understand the connection between "the samples per frame" how changes the signal output just like that?
Also, as you can see, I guess the width of the graph lines has been got thicker than before. That looks interesting as well. How could that thing become possible only changing the samples per frame just like that?
Finally, I added the simulink file with the .slx extension. You can have a look via running the .slx file on your own as well.

Accepted Answer

Paul
Paul on 20 Mar 2022
Edited: Paul on 20 Mar 2022
Question 1: How does the value of the signal dimension ( [5x1] ) was created? I mean which parameter for sine wave dis affect that dimension?
Answer 1: If you turn on Sample Time annotations, it might become clearer. Anyway, the signal dimension is 5 because of the 5 samples per frame. The sample time of the sine wave is 1/1000 seconds/sample. So, at 5 samples/frame, each frame is 5/1000 seconds long. Within a frame, the output of that sine block will have five elements. Over the first frame, the output of the sine block is:
5*sin(2*pi*10*(0:4)/1000)
ans = 1×5
0 0.3140 0.6267 0.9369 1.2434
which you can see if you put a scope on the output of the sine block and zoom in tight from 0 < t < 0.01, for example. After taking the product with the other sine block (also at 5 samples per frame) the output of the product over the first frame is
5*sin(2*pi*10*(0:4)/1000).*5.*sin(2*pi*10*(0:4)/1000)
ans = 1×5
0 0.0986 0.3927 0.8778 1.5462
which again can be seen by zooming in tight on the scope at the output of the product. Same thing happens over the second frame, but with indices 5:9 instead of 0:4.
Question 2: When change the value “samples per frame” of the one of sine waves, (I adjusted one of them 1 and other one is 5) the output signal has been changed just like that below.
When one of the sine blocks is changed to one sample per frame, it becomes a scalar output at a sample time of 1/1000 seconds/sample. But the other sine block is still a 5x1 that is held constant over frame intervals of 5/1000. So the the output of the product is 5 x 1, at a sample time of 0.001. Over the first 0.005 seconds, the output of the product is then
Time = (0:.001:0.004).';
Product = 5*sin(2*pi*10*(0:4)/1000).*5.*sin(2*pi*10*Time);
table(Time,Product)
ans = 5×2 table
Time Product _____ _________________________________________________ 0 0 0 0 0 0 0.001 0 0.098566 0.19674 0.29414 0.39038 0.002 0 0.19674 0.39271 0.58713 0.77923 0.003 0 0.29414 0.58713 0.87779 1.165 0.004 0 0.39038 0.77923 1.165 1.5462
which again can be seen by zooming on the scope of the product over the first 0.005 seconds.
  4 Comments
Paul
Paul on 20 Mar 2022
That box is the "Sample Time Legend" that shows all of the unique sample times in the model and assigns to them an annotation. In this case D1 is the annotation for a sample time of 0.005. If you have sample time annotations turned on, you should see D1 on the signal lines for all signals that have a sample time of 0.005 similar to who the signal dimenstions are shown if you have those turned on, like in the diagram posted in teh Question). FiM is a built-in sample time that Simulink assigns automatically to certain signals in certain situtations. Anyway, you can turn on sample time annotations or sample time colors (each sample time will be assigned a color used to demarcate the signals in the block diagram) or both (using the "All" option). Looking at the sample times is another tool, like showing signal dimensions, that can help with understanding/illustrating/verifying how the simulation works.
cikalekli
cikalekli on 21 Mar 2022
Thank you so much for the detailed explanation. Now, I've understood everything.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!