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 ]
 Matt J Posts: 4,997 Registered: 11/28/09
Re: Indexing Problem
Posted: Jun 25, 2012 2:07 PM

"Michael " <mabowles@syr.edu> wrote in message <jsa8nn\$3qm\$1@newscl01ah.mathworks.com>...
>
> 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!)

===============

I think you really meant to write all_counts(:,1). What you've written would have extracted a 1x8 row.

> 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?

=====================

Works fine for me

>> all_counts=rand(29,8); all_counts(NW,:)

ans =

0.2217 0.7962 0.8865 0.3909 0.3015 0.5830 0.0688 0.6718
0.1174 0.0987 0.0287 0.8314 0.7011 0.2518 0.3196 0.6951
0.0855 0.7212 0.5005 0.4168 0.1781 0.9827 0.7184 0.8444
0.8010 0.6538 0.0596 0.6280 0.9991 0.3439 0.5313 0.7805
0.9880 0.8055 0.8253 0.5479 0.1206 0.6959 0.9577 0.4735
0.0377 0.5767 0.0835 0.9427 0.5895 0.6999 0.2407 0.1527

I would double-check the size of all_counts or NW. If this is happening inside a function, use DBSTOP to halt execution where the error is occuring. Check the dimensions of everything at that moment.

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