Implementing a function in simulink simulation

Click For Summary

Discussion Overview

The discussion revolves around implementing a discrete filter function in a Simulink simulation, specifically focusing on the output behavior of the filter defined by the equation $$y(n)=0.8x(n)+0.5x(n-1)+0.2x(n-2)$$. Participants explore the expected output characteristics when a sine wave is used as the input signal.

Discussion Character

  • Homework-related, Technical explanation, Conceptual clarification

Main Points Raised

  • One participant describes their attempt to implement a filter in Simulink using a sine wave as input and outlines their understanding of the filter's coefficients derived from the z-transform.
  • Another participant questions the expected output of the filter, prompting a discussion about the nature of weighted averages and their impact on amplitude.
  • There is a clarification about how the filter processes three consecutive values of the sine wave, with emphasis on the weights assigned to each value.
  • Participants engage in hypothetical scenarios to evaluate the filter's output when the input values are at different points of the sine wave (near 1, 0, and -1).
  • One participant expresses uncertainty about the output values and attempts to calculate them based on the filter's coefficients.
  • Another participant confirms the calculations and suggests that the output will resemble the sine wave but with modified amplitude characteristics.
  • A later reply notes that the output graph appears blocky, attributing this to sampling frequency issues in the simulation.

Areas of Agreement / Disagreement

Participants generally agree on the nature of the filter's output resembling the input sine wave but with modified amplitude. However, there is uncertainty regarding the exact behavior of the output under different input conditions, and the discussion includes various interpretations and calculations that have not reached consensus.

Contextual Notes

There are limitations regarding the assumptions made about the input signal and the filter implementation in Simulink, as well as the potential effects of sampling frequency on the output waveform.

Evo8
Messages
168
Reaction score
0

Homework Statement



The problem statement essentially has me inputing a signal into simulink manipulating it and then looking at the output.

My output function is defined as $$y(n)=0.8x(n)+0.5x(n-1)+0.2x(n-2)$$

Homework Equations



N/A

The Attempt at a Solution



In my simulink canvas I have placed a sine wave as my source and a scope as the sink or output.

To implement this function i tried the block called discrete filter. I have connected them in series respectively.

When I open the parameters for the filter i have fields for numerator and denominator coefficients. So I took my Y(n) and calculated the z transform then found my H(z).

y(n)=0.8x(n)+0.5z^{-1}x(n)+0.2z^{-2}x(n)
y(n)=x(n)(0.8+0.5z^{-1}+0.2z^{-2})
H(z)=0.8+0.5z^{-1}+0.2z^{-2}

So i put the coefficents into my filter parameters.
Numerator was [0.8 0.5 0.2]
Denominator was [1]

My input sine wave was left at the default of 1amplitude and 1 rad/sec.

My input and parameters:
attachment.php?attachmentid=43532&stc=1&d=1328468335.png

This is what my output looks like.
attachment.php?attachmentid=43531&stc=1&d=1328468023.jpg


Am I on the right track here? I am not really sure what my expected outcome should be.

Thanks for any help.
 

Attachments

  • output.JPG
    output.JPG
    44.5 KB · Views: 510
  • input.PNG
    input.PNG
    20.2 KB · Views: 644
Physics news on Phys.org
Let's see...

So you have a sine input and a filter that does ##y(n)=0.8x(n)+0.5x(n-1)+0.2x(n-2)##.
The filter would take 3 consecutive values of the sine input and replace it by a weighted average.
What kind of output would you expect in such a case?
Can you say anything about the amplitude (since it's a weighted average)?
 
I guess I don't really understand how the weighted average would apply.

So the three consecutive values I assume are 0.8, 0.5 and 0.2? With 0.2 having the least weight? I would suspect that the amplitude would be decreased in certain areas. I am thinking that may not be the case since my output waveform had amplitudes that exceed 1? Of course I am not sure if that filter was implemented properly.
 
Suppose you have 3 consecutive values that are all close to the top of the sine, which is 1.
What would the value of the filter be?

Similarly, suppose you have 3 consecutive values that are all close to 0.
What would the value of the filter be?

Finally, suppose you have 3 consecutive values close to the valley of the sine at value -1.
What would the value of the filter be?
 
Im not sure that I completely follow.

3 consecutive values close to the top of the filter (1) I would guess the value of the filter to be close to 3?

For the values close to 0 i would guess it would be close to 0

For the values close to -1 following the same convention I would guess -3?
 
You have the filter y(n)=0.8x(n)+0.5x(n-1)+0.2x(n-2).

Suppose x(n)=x(n-1)=x(n-2)=1, what would y(n) be?
It would not be 3.
 
Well I would be left with just the coefficients right? So y(n)=1.5
 
Exactly. :)
The same would happen when the sine is around -1.

The resulting output would look like a sine, just like the input, with an amplitude that is more than 1, but less than 1.5.

Does your output graph look like that?
 
It certainly does! Its a bit blocky but that must be my sampling frequency in the simulation. I will have to play with it.

Thanks again for all of your help Ilse. Much appreciated!
 
  • #10
Have fun playing! :smile:
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
Replies
6
Views
4K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
18K
  • · Replies 4 ·
Replies
4
Views
5K