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: subscript error
Replies: 2   Last Post: Mar 13, 2009 9:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
G. B.

Posts: 118
Registered: 2/18/09
Re: subscript error
Posted: Mar 13, 2009 8:45 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"ulas im" <ulasim77@gmail.com> wrote in message <gpdjcp$abo$1@fred.mathworks.com>...
> Dear Matlab users
>
> &#305; am trying to run the short code below but i keep getting the error:
> ??? Assignment has fewer non-singleton rhs dimensions than non-singleton
> subscripts
>
> the error occurs when it runs for the hour 9 and passes to hour 10:
>
> for time=0:23
>
> filename=['FinalEmission_Day1_Spe1_Hour',num2str(time)]; %CO
> load(filename);
> t=num2str(time);
>
> EmmTemp=zeros(163,150,20,24);
>
> EmmTemp(:,:,:,t)=B(:,:,:);
>
> clear B t filename EmmTemp;
>
> end
>
> what is the source of this problem?
>
> Ulas


when you do:

t = num2str(time);

you are assigning a string to "t". you cannot then use "t" as an index in an array.

Then, Matlab has no 0 indexes, it starts at 1, so you should do:

EmmTemp(:,:,:,time+1) = B(:,:,:);

In addition, you are initializing and clearing EmmTemp at each iteration of the for loop, so you won't have anything in the end


Date Subject Author
3/13/09
Read subscript error
ulas
3/13/09
Read Re: subscript error
G. B.
3/13/09
Read Re: subscript error
ulas

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.