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:
Problem

Subject: Problem

From: Syed Umair Uddin

Date: 2 Jun, 2010 19:22:05

Message: 1 of 3

Hi All,
Can anyone help me to find out the following error in the given code.
________________________________________________________________
??? Index exceeds matrix dimensions.

Error in ==> salpha at 28
    R = real(F(u,v)).^2 ;

_________________________________________________________________
Code :
x= 256 ; %16 bit integer

for m=1:x % m=16 bit integer
    for alpha=1:180
      
u(m) = (v(m) ./ (tan(alpha))) ;
v(m) = (u(m) .* (tan(alpha))) ;
   
    R = real(F(u,v)).^2 ; % Line 28
    I = imag(F(u,v)).^2 ;

end

end

Subject: Problem

From: Sadik

Date: 2 Jun, 2010 20:13:20

Message: 2 of 3

Hi Syed,

The problem is your F. That is, the matrix F is smaller than you are assuming.

You haven't given its definition. Can you write that as well?

Best.

Subject: Problem

From: TideMan

Date: 2 Jun, 2010 20:27:35

Message: 3 of 3

On Jun 3, 8:13 am, "Sadik " <sadik.h...@gmail.com> wrote:
> Hi Syed,
>
> The problem is your F. That is, the matrix F is smaller than you are assuming.
>
> You haven't given its definition. Can you write that as well?
>
> Best.

Not only that, but u and v are not necessarily integers, which they
must be if M is a matrix.
Also, u and v are vectors that are increasing in size inside the m
loop, so R and I will be matrices with increasing size.
Unless, of course, F is a function, not a matrix and the OP has
inadvertently redefined it as a matrix.

Also, incrementing alpha from 1 to 180 and using it in tan(alpha)
looks fishy.
Perhaps it should be tand(alpha)?
But then tand(90) is inf and tand(180) is zero, so there will be
problems there.

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