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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

" This Value must be scalar"

akshaykumawat15
3-Newcomer

" This Value must be scalar"

Whenever I Return the value for the program I created, It gives me the error.

Kindly help me out .

Thanks in Advance

ACCEPTED SOLUTION

Accepted Solutions

Apart from what Fred already spotted, some more remarks:

  1. You may consider setting the system variable ORIGIN to 1, instead of the default value 0. You can do this either by writing ORIGIN:=1 at the top of your sheet or via the menu.
    As an alternative you may stick with ORIGIN=0 and change your program to reflect the fact that the first vector element has index nr 0 (loop from 0 to n-1 instead of 1 to n).
  2. Instead of returning a 4x3 matrix or a 12*1 vector (I am assuming you already adopted my remark #1) you may consider returning a nested vector. A vector with the three calculated vectors as elements.
    Werner_E_0-1583600685371.png

     

  3. A severe failure was made by you because you type square brackets in your calculations. Typing square brackets automatically define e vector. You have to use normal parenthesis instead (in some cases they may be displayed as square brackets which is admittedly confusing)

Find a attached a working work sheet (Prime 6). I have assumed that you wanted the full vectors as result. If you really only want the last values (as you created your program initially) you replace epsilon by epsilon[i in the return statements.

Furthermore your program is quite redundant and sure can be written much shorter, but I haven't bothered doing so 😉

View solution in original post

7 REPLIES 7

I think (I've got Express, so I can't change your program to check) that one of your problems is in 

Capture.JPG

this terminology.  This is how FORTRAN (if I recall) specifies elements of a vector.  Mathcad uses a subscript (left square bracket "[") to get  Capture2.JPGinstead.  The notation you used declares a function--put in a value and evaluate the expression, so when you "return e(i)" Mathcad tries to evaluate your function definition, gets confused, and flags an error.  (Mathcad's error messages have never been terribly accurate description of the problem.)

 

Another issue: multiple return statements:

Capture3.JPG

A return statement (I believe) represents a program "break,"  execution halts operations and returns the whatever follows "return".  The next statement would not be executed.  If you replace those three lines with

Capture4.JPG

you can return all three five element vectors as a 5 row three column matrix or as a 15 element vector.  (Yes, five elements, not four!  Mathcad defaults to the first element being 0 unless you change it.  The system variable ORIGIN will tell you what it is.

 

Good luck!

 

@Fred_Kohlhepp 


Mathcad uses a subscript (left square bracket "[") to get  Capture2.JPGinstead. 

In Prime the element of a vector or matrix can be accessed by a matrix subscript as we are used to, but alternatively also via function arguments. Personally I dislike the latter as a vector isn't a function and IMHO this notation is confusing but its valid in Prime.

Werner_E_0-1583596563296.png

But you are correct anyway that the assignment is one of the errors in the sheet, because the function-approach is only allowed on the  right-hand side of an assignment.  In the program one has to use the matrix index.

 

 

 

Thank You So Much !

Apart from what Fred already spotted, some more remarks:

  1. You may consider setting the system variable ORIGIN to 1, instead of the default value 0. You can do this either by writing ORIGIN:=1 at the top of your sheet or via the menu.
    As an alternative you may stick with ORIGIN=0 and change your program to reflect the fact that the first vector element has index nr 0 (loop from 0 to n-1 instead of 1 to n).
  2. Instead of returning a 4x3 matrix or a 12*1 vector (I am assuming you already adopted my remark #1) you may consider returning a nested vector. A vector with the three calculated vectors as elements.
    Werner_E_0-1583600685371.png

     

  3. A severe failure was made by you because you type square brackets in your calculations. Typing square brackets automatically define e vector. You have to use normal parenthesis instead (in some cases they may be displayed as square brackets which is admittedly confusing)

Find a attached a working work sheet (Prime 6). I have assumed that you wanted the full vectors as result. If you really only want the last values (as you created your program initially) you replace epsilon by epsilon[i in the return statements.

Furthermore your program is quite redundant and sure can be written much shorter, but I haven't bothered doing so 😉

LucMeekes
23-Emerald III
(To:Werner_E)

Werner's sheet converted to Prime 3.0 is attached.

Thank you so much for your response, 

Actually I'm a newbie to mathcad so in further programmings ,

I'll try to reduce my redundancy.

& Thanks for the tip.

 

Here is a streamlined version of your program. You may put the definition of the interpolation function "stress" at the top of the program, but I'd prefer to have it outside.

I replaced two if statements by the space saving if-function (a version which uses if statements only is included in the attached Prime 6 worksheet.

Werner_E_0-1583631272164.png

 

 

 

Announcements

Top Tags