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 ]
Roger Stafford

Posts: 5,811
Registered: 12/7/04
Re: Summation over for loop-Subscripted assignment dimension mismatch.
Posted: Dec 9, 2012 6:23 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Vsh" wrote in message <ka0q5o$hvc$1@newscl01ah.mathworks.com>...
> 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. .....
> .........
> 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

- - - - - - - - - - - -
In the line

A(i,j)=B*(XX(i,j).^2-(a1).^2) ,

on the right side you have an entire 10 by 10 matrix product and you are trying to squeeze it into the scalar, A(i,j). It just won't fit! What is it you expect to happen here?

In any case, the expression B*(XX(i,j).^2-(a1).^2) would be an awfully hard way to calculate that result there, which tells me that you meant something altogether different for the right side, presumably something that is also a scalar. Also there is a K counter here which you have made no use of at all. Only you can determine what is "right". However I would hazard the guess that you meant this:

A(i,j) = (-G/pi/(1-v))*(XX(i,j)^2-a^2);

Roger Stafford



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.