Skip to main content
1-Visitor
September 8, 2016
Solved

This Value Must Be an Integer Error in Solve Block

  • September 8, 2016
  • 7 replies
  • 6499 views

I'm trying to make a Mathcad file that can perform some basic statics calculations for a number of different load cases at once. I can get the solve block to work fine with single values for all my inputs, but once I try to start using arrays to run multiple situations at once, I keep getting a "This value must be an integer" error on one of the equations under the Given header. Any ideas, or am I just doing this the wrong way?

Best answer by Werner_E

Generally in cases like this its better to turn the solve block into a function depending on the (here three) input values and implement it for scalars. Then you can call this function with vectors as argument and vectorize that function call.

In your case you would get a 12 x 1 vector and each element would be a 4x1 vector. Obviously not the format you would like the result to be presented. So a small routine creates the result vectors in the format you probably would like them to be.

See if the attached sheet helps.

Werner

7 replies

12-Amethyst
September 9, 2016

Hi.

Hope attached is the solution.

Best regards.

Alvaro.

Werner_E25-Diamond IAnswer
25-Diamond I
September 9, 2016

Generally in cases like this its better to turn the solve block into a function depending on the (here three) input values and implement it for scalars. Then you can call this function with vectors as argument and vectorize that function call.

In your case you would get a 12 x 1 vector and each element would be a 4x1 vector. Obviously not the format you would like the result to be presented. So a small routine creates the result vectors in the format you probably would like them to be.

See if the attached sheet helps.

Werner

12-Amethyst
September 9, 2016

Hi Werner.

Yes, probably it's better to parameterize the solve block by the 'parameters', not by the variables. But in your implementation loose the option for set individual guesses for each case of the variable, even isn't the case in this problem.

Also, can extract the solutions for each variable more easily.

Attached a comparison for both methods, both with one initial condition for each variable (the same, but one for each).

Or, without parameters.

Best regards.

Alvaro.

ex.gif

ex.gif

25-Diamond I
September 9, 2016

> But in your implementation loose the option for set individual guesses for each case of the variable,

Yes thats true. We could easily add four more arguments to the function for the guess values, but as the OP also provided zero as guess for all cases, I decided against a function with seven arguments.

While I usually try to avoid global ranges for the calculations and prefer doing the job using functions and for-loops, I have to admit that your way of separating the solutions looks quite compact and straight forward.

I am still a bit confused why you get the same result in your last screenshot as you have not vectorized and so you have vector scalar products in your solve block. Seems to me like the expressions should be vectorised there.

Werner