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:
Index exceeds matrix dimensions

Subject: Index exceeds matrix dimensions

From: nouha

Date: 23 Mar, 2011 09:14:07

Message: 1 of 2

my program, It returns the error message:

??? Error using ==> Index exceeds matrix dimensions.please help me to resolve this problem and thanks

clc
X=[0.1802,0.2547,0.2955,0.3229,0.3443,0.3631,0.3798,0.3953,0.4101,0.4244,0.4389,0.4534,0.4679,0.4837,0.5005,0.5149,0.5394,0.5641,0.6019,0.6404];
for i=1:20
A=(((2.*X(i))-1).^0).*(((2*2).*X(i))-1);
end
for i=1:20
B=(((2.*X(i))-1).^1).*(((2*3).*X(i))-1);
end
for i=1:20
C=(((2.*X(i))-1).^2).*(((2*4).*X(i))-1);
end
for i=1:20
D=(((2.*X(i))-1).^3).*(((2*5).*X(i))-1);
end
for i=1:20
E=(((2.*X(i))-1).^4).*(((2*6).*X(i))-1);
end
for i=1:20
F=(((2.*X(i))-1).^5).*(((2*7).*X(i))-1);
end
for i=1:20
G=(((2.*X(i))-1).^6).*(((2*8).*X(i))-1);
end
disp('_________________________________________________________')
disp(' X A B C D E F G ')
disp('_________________________________________________________')

for i=1:20
fprintf('%10.4f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f\n',X(i),A(i),B(i),C(i),D(i),E(i),F(i),G(i))
end

Subject: Index exceeds matrix dimensions

From: Alexander Sotnikov

Date: 23 Mar, 2011 09:22:13

Message: 2 of 2

Instead of
> for i=1:20 A=(((2.*X(i))-1).^0).*(((2*2).*X(i))-1);
> end
you should write
for i=1:20 A(i)=(((2.*X(i))-1).^0).*(((2*2).*X(i))-1);
end
and so on

--

Alexander

Tags for this Thread

No tags are associated with 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