Index exceeds matrix dimensions.
Show older comments
I get error message 'Index exceeds matrix dimensions' wiht the following code. I will appreciate help.
for i = 1:length( Vmean ),
GroupMean = GroupMean + Vmean{i}.Y(1,strt:fnsh);
GroupStd = GroupStd + Vstd{i}.Y(1,strt:fnsh);
Answers (2)
"fnsh" is greater than the length of either Vmean{i}.Y or Vstd{i}.Y
Hence, there is nothing there for Vmean{i}.Y(fnsh) or or Vstd{i}.Y(fnsh) to grab.
Use
>>dbstop if error
to find the offending i.
Image Analyst
on 25 Dec 2014
I suggest you make fnsh not more than the number of columns in Y. What does this say
theYarray = Vmean{1}.Y;
whos theYarray
The whos command will tell you how many rows and columns are in Y. See if the number of columns is less than fnsh. If it is, then you need to figure out why you're trying to specify fnsh with the value that you did.
6 Comments
Rajendra
on 25 Dec 2014
Rajendra
on 25 Dec 2014
Rajendra
on 25 Dec 2014
Image Analyst
on 25 Dec 2014
You called it Vmean, not V.mean. Anyway, did you try my second/last suggestion (the link)?
Rajendra
on 27 Dec 2014
Image Analyst
on 27 Dec 2014
We can't really do much more unless you upload the program and the data so we can then use the debugger to step through your code (same as what I asked you to do). Using the debugger and finding out what the dimensions and indexes are is the way to solve this problem. If you can't do it then we/someone might do it for you but we require code and data.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!