Could someone please tell me whats wrong with my code?
h = MTT{m}(MSchJ{m}(end),:);
MAXP = [MAXP; max(h(isfinite(MTT{m}(MSchJ{m}(end),:)),1))];
This is the error I get:
??? Index exceeds matrix dimensions.
Error in ==> SAPSLMETARAPS at 197
MAXP = [MAXP; max(h(isfinite(MTT{m}(MSchJ{m}(end),:)),1))];
Thanks,
Diego
|
|
0
|
|
|
|
Reply
|
diegozbb (116)
|
10/28/2008 5:42:02 PM |
|
"Diego Zegarra" <diegozbb@gmail.com> wrote in message <ge7ita$jdd$1@fred.mathworks.com>...
> Could someone please tell me whats wrong with my code?
> h = MTT{m}(MSchJ{m}(end),:);
> MAXP = [MAXP; max(h(isfinite(MTT{m}(MSchJ{m}(end),:)),1))];
That is equivalent to
MAXP = [MAXP; max(h(isfinite(h),1))];
Did you perhaps mean
MAXP = [MAXP; max(h(isfinite(h)),1)];
that is, taking the maximum along the first dimension
rather than access the first column of h?
We can see from the definition of h that is expected
to be exactly one entire row, so it is going to be 1 x something.
isfinite(h) would be the same size, 1 x something.
You then use that 1 x something logical array as the -first-
index of h rather than as the -second- index of h, as if you
were attempting to access a something x 1 array. And since it
doesn't have all those rows and you explicitly specified the
second dimension it knows that you aren't just using logical
indexing relative to the beginning of the array... so it bombs out.
|
|
0
|
|
|
|
Reply
|
roberson2 (8067)
|
10/28/2008 9:33:01 PM
|
|