cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Arrray Invalid Array Error: Analysing Failure using Monte Carlo simulation

awibroe
14-Alexandrite

Arrray Invalid Array Error: Analysing Failure using Monte Carlo simulation

I am very new to Mathcad and am trying to complete an assignment in which I need to calculate the number of occurrences whereby load of a system is greater than resistance. I have created my file and programme in line with my course notes but at the end am getting an error message stating that the array in my if statement is invalid. I attach file for anyone that can help.

Thank you

Andy.

1 ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald II
(To:awibroe)

Andy Wibroe wrote:

I am very new to Mathcad and am trying to complete an assignment in which I need to calculate the number of occurrences whereby load of a system is greater than resistance. I have created my file and programme in line with my course notes but at the end am getting an error message stating that the array in my if statement is invalid. I attach file for anyone that can help.

First, Mathcad's default index origin is 0 (zero) not 1 (one) - unlike some (eg, Matlab).  But you can change it to 1 if you prefer.

Second, histogram doesn't return NSim rows (values). This gives your error, as Mathcad is trying to address an index that doesn't exist.  Create a new range variable of the exact size, using the function rows.

Third, you could use the new range variable to replace ir in your sum, but it's far simpler just to use the summation operator without the range variable - Mathcad will assume you want to sum over the entire vector.

Stuart

View solution in original post

4 REPLIES 4
StuartBruff
23-Emerald II
(To:awibroe)

Andy Wibroe wrote:

I am very new to Mathcad and am trying to complete an assignment in which I need to calculate the number of occurrences whereby load of a system is greater than resistance. I have created my file and programme in line with my course notes but at the end am getting an error message stating that the array in my if statement is invalid. I attach file for anyone that can help.

First, Mathcad's default index origin is 0 (zero) not 1 (one) - unlike some (eg, Matlab).  But you can change it to 1 if you prefer.

Second, histogram doesn't return NSim rows (values). This gives your error, as Mathcad is trying to address an index that doesn't exist.  Create a new range variable of the exact size, using the function rows.

Third, you could use the new range variable to replace ir in your sum, but it's far simpler just to use the summation operator without the range variable - Mathcad will assume you want to sum over the entire vector.

Stuart

awibroe
14-Alexandrite
(To:StuartBruff)

‌Hi Stuart,

i can't tell you how greatful  am for such a quick answer. As a noob to MathCAD, can you give me any advice/ tell me where i can go to learn how to carry out your recommendations?

THanks,

ANdy

StuartBruff
23-Emerald II
(To:awibroe)

Hi Andy,

This forum is a good place to learn - there's usually somebody around to answer newcomers' questions.

Another place is the Help and Examples in Mathcad.

Stuart

VladimirN
24-Ruby II
(To:awibroe)

I recommend a book by Brent Maxfield "Engineering with Mathcad".

Top Tags