Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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.
Solved! Go to Solution.
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
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
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
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
I recommend a book by Brent Maxfield "Engineering with Mathcad".