Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Indexing Problem
Replies: 1   Last Post: Jun 25, 2012 2:07 PM

 Messages: [ Previous | Next ]
 Michael Posts: 12 Registered: 6/18/12
Indexing Problem
Posted: Jun 25, 2012 1:56 PM

Hello all,

I have a matrix 'all_counts' (29 by 8 array containing data, and some NaNs). I'm trying to graph certain parts. I'm using (I believe) logicals to do this.

I've defined:

% define location vector, to be used for cuts
src_loc = [ 1 1 2 2 3 1 1 3 2 1 2 1 3 3 1 3 1 1 1 1 3 1 1 3 1 3 1 2 2 ]; % (29 entries)
% Define actual positions
SW=src_loc==1;
NW=src_loc==2;
NE=src_loc==3;

Which all work properly when I ask MATLAB what they are.. (e.g. SW = row vector of 1's and 0's, and likewise for NW and NE). Here's the messed up part... I can try

all_counts(1,:) --- this gives a 29-by-1 column of data (good!)
all_counts(SW,:) --- this gives all data from the Southwest source position (which is what I want)

...but when I try:
all_counts(NW,:)
I get:
Index exceeds matrix dimensions.

What is going on here? I've tried 'clear all' and re-importing my 'all_counts' as well as the position definintion for SW, NW and NE. I really only get this error with the NW position (no matter which column I try to pick out) which is unlike my other positions calls (SW, NE)... how can I fix this?

Thank you for any help. If I've been unclear please just tell me how to clarify!!!

-Michael

Date Subject Author
6/25/12 Michael
6/25/12 Matt J