Skip to main content
1-Visitor
March 9, 2016
Solved

Arrray Invalid Array Error: Analysing Failure using Monte Carlo simulation

  • March 9, 2016
  • 4 replies
  • 1701 views

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.

Best answer by StuartBruff

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

4 replies

23-Emerald V
March 10, 2016

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

awibroe1-VisitorAuthor
1-Visitor
March 10, 2016

‌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

23-Emerald V
March 10, 2016

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