Been modelling a system using simulink. At one point in the system I tap of a signal (consisting of a couple of sine waves ie sin(w1t) and sin(w2t)), do a 2048 point FFT and have the results displayed using the graphing capability in simulink. The simulation time is about 10 seconds. On the spectrum plot I expect to see a difference of 6dB level between sin(w1t) and sin(w2t).What I actually get is this - when simulation is active, ie the 10 seconds is not up yet, I notice a 4dB difference. As soon as the simulation ends, right after 10 seconds, boom, the spectrum shows the correct dB level difference between the two sine waves ie 6dB, Question - anyone else see this difference in the behaviour of simulink when doing spectrum displays, ie one for the case when the simulation is running and the other when simulink has just stopped simulating ? Should results be examined only after a simulation session is completed ?
Spectrum plots in MATLAB/Spectrum
Started by ●September 8, 2004
Reply by ●September 8, 20042004-09-08
Ted wrote:> Been modelling a system using simulink. At one point in the system I > tap of a signal (consisting of a couple of sine waves ie sin(w1t) and > sin(w2t)), do a 2048 point FFT and have the results displayed using > the graphing capability in simulink. The simulation time is about 10 > seconds. > > On the spectrum plot I expect to see a difference of 6dB level between > sin(w1t) and sin(w2t).What I actually get is this - when simulation is > active, ie the 10 seconds is not up yet, I notice a 4dB difference. As > soon as the simulation ends, right after 10 seconds, boom, the > spectrum shows the correct dB level difference between the two sine > waves ie 6dB, > > Question - anyone else see this difference in the behaviour of > simulink when doing spectrum displays, ie one for the case when the > simulation is running and the other when simulink has just stopped > simulating ? > > Should results be examined only after a simulation session is > completed ?Why do you expect any difference at all? The spectral lines should be proportional to amplitude, and both amplitudes are the same. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●September 9, 20042004-09-09
ed_ted_ed@yahoo.com (Ted) wrote in message news:<39c154be.0409081457.309b561a@posting.google.com>...> Been modelling a system using simulink. At one point in the system I > tap of a signal (consisting of a couple of sine waves ie sin(w1t) and > sin(w2t)), do a 2048 point FFT and have the results displayed using > the graphing capability in simulink. The simulation time is about 10 > seconds. > > On the spectrum plot I expect to see a difference of 6dB level between > sin(w1t) and sin(w2t).What I actually get is this - when simulation is > active, ie the 10 seconds is not up yet, I notice a 4dB difference. As > soon as the simulation ends, right after 10 seconds, boom, the > spectrum shows the correct dB level difference between the two sine > waves ie 6dB, > > Question - anyone else see this difference in the behaviour of > simulink when doing spectrum displays, ie one for the case when the > simulation is running and the other when simulink has just stopped > simulating ? > > Should results be examined only after a simulation session is > completed ?What the DSP is concerned, it would be nice to have some more information about the signal, like sampling frequency, signal amplitudes, the actual values of your frequencies, etc. What simulink is concerned, you might want to cross-post to comp.soft-sys.matlab, where you are likely to find the simulink wizards. Rune
Reply by ●September 9, 20042004-09-09
Rune Allnor wrote:> ed_ted_ed@yahoo.com (Ted) wrote in message > news:<39c154be.0409081457.309b561a@posting.google.com>... >> Been modelling a system using simulink. At one point in the >> system I tap of a signal (consisting of a couple of sine waves ie >> sin(w1t) and sin(w2t)), do a 2048 point FFT and have the results >> displayed using the graphing capability in simulink. The >> simulation time is about 10 seconds. >> >> On the spectrum plot I expect to see a difference of 6dB level >> between sin(w1t) and sin(w2t).What I actually get is this - when >> simulation is active, ie the 10 seconds is not up yet, I notice a >> 4dB difference. As soon as the simulation ends, right after 10 >> seconds, boom, the spectrum shows the correct dB level difference >> between the two sine waves ie 6dB, >> >> Question - anyone else see this difference in the behaviour of >> simulink when doing spectrum displays, ie one for the case when >> the simulation is running and the other when simulink has just >> stopped simulating ? >> >> Should results be examined only after a simulation session is >> completed ?I don't think so. But be aware that during simulation, not all blocks of your simulation are updated in real time. Check the simulation properties page, especially.> > What the DSP is concerned, it would be nice to have some more > information about the signal, like sampling frequency, signal > amplitudes, the actual values of your frequencies, etc. > > What simulink is concerned, you might want to cross-post to > comp.soft-sys.matlab, where you are likely to find the simulink > wizards. > > RuneTo my experience, you find real Matlab wizards, and lots of. But there are obviously not so many simulink users and even less wizards there - don't know why. Just one hint: usually, there are storage limitations activated, when you run your simulation. After it has terminated, intermediate results are thrown away and you see only lets say the last 5000 points. During simulation, you get an intermediate result displayed, as soon as enough information is available. Then, calculation seems to have precedence and display is hardly refreshed, until all calculation has finished. In your case there might be an initial error which is displayed in the beginning and which has faded away once simulation is done. If your setup allows it, set your simulation (end) time to 'inf', and watch the results. If my expectation is correct, you'd see the 4dB difference in the beginning - then after some time it should change to the 'correct' values. If not, there's another effect. Bernhard
Reply by ●September 9, 20042004-09-09
Bernhard Holzmayer wrote:> Rune Allnor wrote: > > >>ed_ted_ed@yahoo.com (Ted) wrote in message >>news:<39c154be.0409081457.309b561a@posting.google.com>... >> >>>Been modelling a system using simulink. At one point in the >>>system I tap of a signal (consisting of a couple of sine waves ie >>>sin(w1t) and sin(w2t)), do a 2048 point FFT and have the results >>>displayed using the graphing capability in simulink. The >>>simulation time is about 10 seconds. >>> >>>On the spectrum plot I expect to see a difference of 6dB level >>>between sin(w1t) and sin(w2t).What I actually get is this - when >>>simulation is active, ie the 10 seconds is not up yet, I notice a >>>4dB difference. As soon as the simulation ends, right after 10 >>>seconds, boom, the spectrum shows the correct dB level difference >>>between the two sine waves ie 6dB, >>> >>>Question - anyone else see this difference in the behaviour of >>>simulink when doing spectrum displays, ie one for the case when >>>the simulation is running and the other when simulink has just >>>stopped simulating ? >>> >>>Should results be examined only after a simulation session is >>>completed ? > > I don't think so. But be aware that during simulation, not all > blocks of your simulation are updated in real time. > Check the simulation properties page, especially. > > >>What the DSP is concerned, it would be nice to have some more >>information about the signal, like sampling frequency, signal >>amplitudes, the actual values of your frequencies, etc. >> >>What simulink is concerned, you might want to cross-post to >>comp.soft-sys.matlab, where you are likely to find the simulink >>wizards. >> >>Rune > > > To my experience, you find real Matlab wizards, and lots of. > But there are obviously not so many simulink users and even less > wizards there - don't know why. > > Just one hint: usually, there are storage limitations activated, > when you run your simulation. After it has terminated, intermediate > results are thrown away and you see only lets say the last 5000 > points. During simulation, you get an intermediate result > displayed, as soon as enough information is available. > Then, calculation seems to have precedence and display is hardly > refreshed, until all calculation has finished. > In your case there might be an initial error which is displayed in > the beginning and which h asfadedawayoncesimulationisdone. > > If your setup allows it, set your simulation (end) time to 'inf', > and watch the results. If my expectation is correct, you'd see the > 4dB difference in the beginning - then after some time it should > change to the 'correct' values. If not, there's another effect. > > BernhardAm I the only one who believes that the spectrum of [sin(wt) + sin(2wt)] should consist of two lines of equal length? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●September 9, 20042004-09-09
Jerry, there 2 reasons why they may not be the same level. 1) Ted wrote that the components were sin(2piFt) and sin(4piFt), here really didn't say their magnitudes were equal. 2) Even if their magnitudes were equal, if the the tonals do not lie directly on an FFT bin, then spectral leakage occurs resulting in different magnitudes. The amount of leakage depends on the type of window used, and on the relative frequency locations with respect to the FFT frequency bins. Cheers, David Jerry Avins <jya@ieee.org> wrote in message news:<413fa6d7$0$6912$61fed72c@news.rcn.com>...> Ted wrote: > > Been modelling a system using simulink. At one point in the system I > > tap of a signal (consisting of a couple of sine waves ie sin(w1t) and > > sin(w2t)), do a 2048 point FFT and have the results displayed using > > the graphing capability in simulink. The simulation time is about 10 > > seconds. > > > > On the spectrum plot I expect to see a difference of 6dB level between > > sin(w1t) and sin(w2t).What I actually get is this - when simulation is > > active, ie the 10 seconds is not up yet, I notice a 4dB difference. As > > soon as the simulation ends, right after 10 seconds, boom, the > > spectrum shows the correct dB level difference between the two sine > > waves ie 6dB, > > > > Question - anyone else see this difference in the behaviour of > > simulink when doing spectrum displays, ie one for the case when the > > simulation is running and the other when simulink has just stopped > > simulating ? > > > > Should results be examined only after a simulation session is > > completed ? > > Why do you expect any difference at all? The spectral lines should be > proportional to amplitude, and both amplitudes are the same. > > Jerry
Reply by ●September 9, 20042004-09-09
Dave Kirkland wrote:> Jerry, there 2 reasons why they may not be the same level. > > 1) Ted wrote that the components were sin(2piFt) and sin(4piFt), here > really didn't say their magnitudes were equal.In that case, one of them would have been sin(2piFt) and the other, Asin(4piFt), with A ~=1. Or am I too literal minded?> 2) Even if their magnitudes were equal, if the the tonals do not lie > directly on an FFT bin, then spectral leakage occurs resulting in > different magnitudes. The amount of leakage depends on the type of > window used, and on the relative frequency locations with respect to > the FFT frequency bins.Of course, but the Ted wrote that he expected a difference. I asked why, but got no answer. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●September 9, 20042004-09-09
Dave Kirkland wrote:> Jerry, there 2 reasons why they may not be the same level. > > 1) Ted wrote that the components were sin(2piFt) and sin(4piFt), here > really didn't say their magnitudes were equal.Then if one component were sin(2piFt) the other would need to be Asin(4piFt), with A not equal to 1. Or am I too literal minded?> 2) Even if their magnitudes were equal, if the the tonals do not lie > directly on an FFT bin, then spectral leakage occurs resulting in > different magnitudes. The amount of leakage depends on the type of > window used, and on the relative frequency locations with respect to > the FFT frequency bins.Of course, but Ted wrote that he expected to see a 6 dB difference, I asked why, but got no answer. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●September 10, 20042004-09-10
"Jerry Avins" schrieb> Dave Kirkland wrote: > > > Jerry, there 2 reasons why they may not be the same level. > > > > 1) Ted wrote that the components were sin(2piFt) and sin > > (4piFt), here really didn't say their magnitudes were > > equal. > > Then if one component were sin(2piFt) the other would need to > be Asin(4piFt), with A not equal to 1. Or am I too literal > minded? > > > 2) Even if their magnitudes were equal, if the the tonals > > do not lie directly on an FFT bin, then spectral leakage > > occurs resulting in different magnitudes. The amount of > > leakage depends on the type of window used, and on the > > relative frequency locations with respect to > > the FFT frequency bins. > > Of course, but Ted wrote that he expected to see a 6 dB > difference, I asked why, but got no answer.And perhaps a third reason: 3) Depending on where he measures the signal, the transfer function at this point might have changed the relative amplitudes of the two frequencies. Transient effects (filter settling time) or effects of the mathematical simulation might account for the difference being "only" 4 dB instead of 6 dB. I didn't read in the original post any rigorous statement as to: - what the input signal is ["consisting of a couple of sine waves ie sin(w1t) and sin(w2t)" -> the assumption here is x = sin(w1t)+sin(w2t)] - where the signal is measured x (input) ----> H1(z) ----> H2(z) ----> y (output) +-->here? +-->here? +-->here? I assume the output (y) ["At one point in the system I tap of a signal"]. Regards Martin
Reply by ●September 10, 20042004-09-10
Jerry Avins <jya@ieee.org> wrote in message news:<41407ee3$0$6917$61fed72c@news.rcn.com>...> Bernhard Holzmayer wrote: > > Rune Allnor wrote: > > > > > >>ed_ted_ed@yahoo.com (Ted) wrote in message > >>news:<39c154be.0409081457.309b561a@posting.google.com>... > >> > >>>Been modelling a system using simulink. At one point in the > >>>system I tap of a signal (consisting of a couple of sine waves ie > >>>sin(w1t) and sin(w2t)), do a 2048 point FFT and have the results > >>>displayed using the graphing capability in simulink. The > >>>simulation time is about 10 seconds. > >>> > >>>On the spectrum plot I expect to see a difference of 6dB level > >>>between sin(w1t) and sin(w2t).What I actually get is this - when > >>>simulation is active, ie the 10 seconds is not up yet, I notice a > >>>4dB difference. As soon as the simulation ends, right after 10 > >>>seconds, boom, the spectrum shows the correct dB level difference > >>>between the two sine waves ie 6dB, > >>> > >>>Question - anyone else see this difference in the behaviour of > >>>simulink when doing spectrum displays, ie one for the case when > >>>the simulation is running and the other when simulink has just > >>>stopped simulating ? > >>> > >>>Should results be examined only after a simulation session is > >>>completed ? > > > > I don't think so. But be aware that during simulation, not all > > blocks of your simulation are updated in real time. > > Check the simulation properties page, especially. > > > > > >>What the DSP is concerned, it would be nice to have some more > >>information about the signal, like sampling frequency, signal > >>amplitudes, the actual values of your frequencies, etc. > >> > >>What simulink is concerned, you might want to cross-post to > >>comp.soft-sys.matlab, where you are likely to find the simulink > >>wizards. > >> > >>Rune > > > > > > To my experience, you find real Matlab wizards, and lots of. > > But there are obviously not so many simulink users and even less > > wizards there - don't know why. > > > > Just one hint: usually, there are storage limitations activated, > > when you run your simulation. After it has terminated, intermediate > > results are thrown away and you see only lets say the last 5000 > > points. During simulation, you get an intermediate result > > displayed, as soon as enough information is available. > > Then, calculation seems to have precedence and display is hardly > > refreshed, until all calculation has finished. > > In your case there might be an initial error which is displayed in > > the beginning and which h asfadedawayoncesimulationisdone. > > > > If your setup allows it, set your simulation (end) time to 'inf', > > and watch the results. If my expectation is correct, you'd see the > > 4dB difference in the beginning - then after some time it should > > change to the 'correct' values. If not, there's another effect. > > > > Bernhard > > Am I the only one who believes that the spectrum of [sin(wt) + sin(2wt)] > should consist of two lines of equal length? > > JerryNope. But there is insufficient information in the original post to make up any opinion as of what one should see in this particular case. The frequencies are given as w1t and w2t which I (perhaps unjustified) interpret as w_1*t and w_2*t, with w_1 and w_2 arbitrary. Second, there is no amplitude information. No explanation is given to why the OP expects to see a 6 dB difference in level. Last, there is the question of exactly how simulink does its voodoo during the simulation. Rune






