Skip to main content
4-Participant
March 12, 2024
Solved

this array elements must be scalar

  • March 12, 2024
  • 1 reply
  • 1154 views

can anyone please help me with following:

ptc5185015_1-1710234480447.png

 

Worked well in Mathcad 15, Prime 9 doesn't like it... Best regards

 

 

 

Best answer by Werner_E

Can not tell from the picture alone what the culprit may be.

Unless you expect a single value es result for the last expression (vector dot product) I guess that the expression needs vectorization.

For further help you should attach a worksheet. Preferably one with stripped down sample data not needing the Excel sheet which does show the same error.

 

Furthermore your program should return a value for ANY input (LoadCase) even though you may think that the case can not exist.
Your program so far does not provide a return value for LoadCase <100, LoadCase>408 and LoadCase in the range from 208 to 400! Guess this is the reason for the error.

You are on the safe side if you use "else if" and "else" and also explicit "return" statements (not mandatory, but good style).

Werner_E_1-1710243084809.png

You may omit the return statements

Werner_E_3-1710243613435.png

or you may omit the "else" branches

Werner_E_4-1710243641433.png

but not both (as otherwise the result would always be 0 or whatever you choose as return value for LoadCases not in the two ranges [100;208] or [400;408])

You may also use the if-function instead of the programmed if-statement

Werner_E_5-1710243793124.png

and you may even create the very same vector without using the range "r" is as follows:

Werner_E_2-1710243134661.png

Note that the expression has to be vectorized.

 

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
March 12, 2024

Can not tell from the picture alone what the culprit may be.

Unless you expect a single value es result for the last expression (vector dot product) I guess that the expression needs vectorization.

For further help you should attach a worksheet. Preferably one with stripped down sample data not needing the Excel sheet which does show the same error.

 

Furthermore your program should return a value for ANY input (LoadCase) even though you may think that the case can not exist.
Your program so far does not provide a return value for LoadCase <100, LoadCase>408 and LoadCase in the range from 208 to 400! Guess this is the reason for the error.

You are on the safe side if you use "else if" and "else" and also explicit "return" statements (not mandatory, but good style).

Werner_E_1-1710243084809.png

You may omit the return statements

Werner_E_3-1710243613435.png

or you may omit the "else" branches

Werner_E_4-1710243641433.png

but not both (as otherwise the result would always be 0 or whatever you choose as return value for LoadCases not in the two ranges [100;208] or [400;408])

You may also use the if-function instead of the programmed if-statement

Werner_E_5-1710243793124.png

and you may even create the very same vector without using the range "r" is as follows:

Werner_E_2-1710243134661.png

Note that the expression has to be vectorized.

 

4-Participant
March 12, 2024

Werner_E - thank you for your prompt reply and number of options for solution . All tested and working.  All best