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

1-Newbie

## This Value Must Be an Integer Error in Solve Block

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?

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V

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 7
9-Granite

Hi.

Hope attached is the solution.

Best regards.

Alvaro.

24-Ruby V

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

9-Granite
(To:Werner_E)

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.

24-Ruby V
(To:AlvaroDíaz)

> 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

9-Granite
(To:Werner_E)
 Werner Exinger wrote: 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.

Hi. Me too. It's a strange result. The solve part, Find, in yellow, works how knows why, and if it was in red it's ok for me, but not, make the vector without the range variable. I attach the file, just in case.

Best regards.

Alvaro.

24-Ruby V
(To:AlvaroDíaz)

I had not looked close enough at the equations in the solve block and so I was wrong in thinking that vectorization would be necessary. There is not a single product of two vectors in the calculation terms. One of the factors always is a scalar. So its all OK and the solve block works as expected.

1-Newbie
(To:Werner_E)

Thanks guys! Using the solve block as a function was exactly what I was looking for. I used Werner's solve block method as I don't care about individual guess values. I reformatted the solution using Alvaro's method, as that seemed a little simpler and straightforward to me, as you said, but everything seems to be working properly now. Thanks!

Announcements