Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Summation over for loop-Subscripted assignment dimension mismatch.
Replies: 2   Last Post: Dec 9, 2012 6:23 PM

 Messages: [ Previous | Next ]
 Vsh Posts: 14 Registered: 12/8/12
Summation over for loop-Subscripted assignment dimension mismatch.
Posted: Dec 8, 2012 8:40 PM

Hi guys, I'm trying to get the summation over for loop statement for A(i,j). First, I'm not sure if i'm doing the whole summation right, secondly, I get a subscripted assignment dimension mismatch error, but I quiet don't understand why. Thanks for the help.

clear all
close all

%Crack length
b=10;
% # of elements on the line
N=10;
% Poisson's ratio
v=0.1;
%Pressure
PR=1;
%Shear modulus
G=1000;
%BE Length
a=b/N;

x=linspace(0,b,2*N+1);
y=x;

for i=1:N
X(i)=x(2*i-1)+a/2;
end

xp=X';

XX=zeros(N,N);

for i=1:N
for j=1:N
XX(i,j)=xp(i)-xp(j);
end
XX(i,i)=a/N^2;
end

B=(-G/pi/(1-v))*ones(N,N);
a1=a*ones(N,N);

K=1;
A=ones(N,N);
for i=1:N
for j=1:N
A(i,j)=B*(XX(i,j).^2-(a1).^2)
end
K=K+1;
end

Date Subject Author
12/8/12 Vsh
12/8/12 neuronet
12/9/12 Roger Stafford