"ulas im" <email@example.com> wrote in message <firstname.lastname@example.org>... > Dear Matlab users > > ı 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