Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- This Array Index is Invalid for This Array - NonMi...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-25-2013
05:45 PM

07-25-2013
05:45 PM

Hi,

I'm trying to write a worksheet for some experiments that I carried out. Within the data sets are a number of NaNs, so I've put some code in to find the NonMissingMean, as I have to find the mean of different column vectors. The code is fine for NonMissingMean(D), where D is my data file, but when I try NonMissingMean(D^<2>) i.e. the mean of all data in column 2 that is a number, it says "this array index is not valid for this array".

I'm hoping someone here knows why this is, and possible ways of fixing it.

Thank you very much for your help in advance.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-25-2013
07:26 PM

07-25-2013
07:26 PM

we would need your data file to see where the problem occurs.

BTW it's rather confusing and unclear to spread the calculations over six pages width! At least I won't look at that kind of sheet in more detail.

Nevertheless I can image why your routine fails if the argument is just a one column vector: cols(M) returns 1. Your for-loop therefore runs down from 1 to zero and at first you try to access M_column<1> which does not exist --> error

Changing the rouitine to the following should solve the problem (additionally the first assignment assures that filterNaN() will not fail if no NaN is present in the vector/matrix):

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-25-2013
07:26 PM

07-25-2013
07:26 PM

we would need your data file to see where the problem occurs.

BTW it's rather confusing and unclear to spread the calculations over six pages width! At least I won't look at that kind of sheet in more detail.

Nevertheless I can image why your routine fails if the argument is just a one column vector: cols(M) returns 1. Your for-loop therefore runs down from 1 to zero and at first you try to access M_column<1> which does not exist --> error

Changing the rouitine to the following should solve the problem (additionally the first assignment assures that filterNaN() will not fail if no NaN is present in the vector/matrix):

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-25-2013
07:34 PM

07-25-2013
07:34 PM

Re: This Array Index is Invalid for This Array - NonMissingMean

Your program starts by defining newM <- M<0>.

Then you create a loop that stacks the other columns on top for i :=1 to cols(M)-1.

But if you send a single column vector there is no column 1, "this array index is not valid "for a single vector column array.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-25-2013
07:43 PM

07-25-2013
07:43 PM

Re: This Array Index is Invalid for This Array - NonMissingMean

Thanks for you reply Fred. I understand what you mean, but how can I modify either the loop to account for single vector column arrays, or change the manner in which I call for the NonMissingMean?

Thanks again