Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
feedback circuit help urgently required

Subject: feedback circuit help urgently required

From: darren

Date: 15 Apr, 2010 17:35:21

Message: 1 of 2

I am trying to design in matlab a feedback circuit, however I am struggling with this concept. I have placed my code below for a 2 coefficient IIR filter. The issue is that I get this error:
??? Attempted to access y(2); index out of bounds because numel(y)=1.

Error in ==> Feed_Back_2_Coefficients at 7
    y(n)=b(1)*y(n-1) + b(2)*y(n) + a(1)*x(n)+ a(2)*x(n-1)

Could someone please help me as I am going round in circles.

clear all
x = 1;
y = 0;
a=[0.6,0.4]
b=[0,-0.1]
for n=2:4;
    y(n)=b(1)*y(n-1) + b(2)*y(n) + a(1)*x(n)+ a(2)*x(n-1)
end
figure(2);stem(y).

Subject: feedback circuit help urgently required

From: Jeremy

Date: 15 Apr, 2010 22:26:04

Message: 2 of 2

"darren " <darrenabrown@msn.com> wrote in message <hq7iop$djg$1@fred.mathworks.com>...
> I am trying to design in matlab a feedback circuit, however I am struggling with this concept. I have placed my code below for a 2 coefficient IIR filter. The issue is that I get this error:
> ??? Attempted to access y(2); index out of bounds because numel(y)=1.
>
> Error in ==> Feed_Back_2_Coefficients at 7
> y(n)=b(1)*y(n-1) + b(2)*y(n) + a(1)*x(n)+ a(2)*x(n-1)
>
> Could someone please help me as I am going round in circles.
>
> clear all
> x = 1;
> y = 0;
> a=[0.6,0.4]
> b=[0,-0.1]
> for n=2:4;
> y(n)=b(1)*y(n-1) + b(2)*y(n) + a(1)*x(n)+ a(2)*x(n-1)
> end
> figure(2);stem(y).

You're trying to access y(2) when solving for y(2). Even if it got past that, it would hit x(2) and you would have the same error, because you have no value for x(2). This is an implicit problem and you're going to need to solve using a numerical method i believe. Past that, i can't help because i don't know how to solve an implicit equation when two variables are unkown.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us