Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Vsh

Posts: 13
Registered: 12/8/12
Summation over for loop-Subscripted assignment dimension mismatch.
Posted: Dec 8, 2012 8:40 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.