Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Whenever I Return the value for the program I created, It gives me the error.
Kindly help me out .
Thanks in Advance
Solved! Go to Solution.
Apart from what Fred already spotted, some more remarks:
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 😉
I think (I've got Express, so I can't change your program to check) that one of your problems is in
this terminology. This is how FORTRAN (if I recall) specifies elements of a vector. Mathcad uses a subscript (left square bracket "[") to get instead. 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:
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
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!
Mathcad uses a subscript (left square bracket "[") to get instead.
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.
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:
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 😉
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.