Signals Question difference equation: Write a function y=diffeqn(a,x,yn1) which computes the output y[n] determined by the first-order system y[n]=ay[n-1]+x[n]
Ältere Kommentare anzeigen
I need to Write a function y=diffeqn(a,x,yn1) which computes the output y[n] of the causal system determined by the first-order autoregression system y[n]=ay[n-1]+x[n] The input vector x, contains x[n] for 0 ≤ n ≤ N − 1 and yn1 supplies the value of y[-1]. The output vector y contains y[n] for 0 ≤ n ≤ N − 1.
Note that y[−1] is necessary for computing y[0], which is the first step of autoregression. Use a for loop in your M-file to compute
5 Kommentare
Rick Rosson
am 10 Sep. 2014
What have you tried so far?
Star Strider
am 10 Sep. 2014
Note that MATLAB uses parentheses, not square brackets, to denote subscripts.
Tucker Russ
am 10 Sep. 2014
Rick Rosson
am 11 Sep. 2014
I don't think you need a function within a function. Instead, you need a function that computes y as required and then a script that calls your function once or perhaps several times to test out your function.
Akzeptierte Antwort
Weitere Antworten (1)
Rick Rosson
am 11 Sep. 2014
Bearbeitet: Rick Rosson
am 11 Sep. 2014
Here's a start. Create a file called diffeqn.m and insert the following code:
function y = diffeqn(a,x,yn1)
% Number of rows:
N = size(x,1);
% Pre-allocate:
y = zeros(N,1);
y(1) = ...
for k = 2:N
...
...
...
end
end
1 Kommentar
Tucker Russ
am 11 Sep. 2014
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!