Solved
Must be a scalar or a matrix
- January 18, 2013
- 2 replies
- 29625 views
Hi all,
I am trying to add two range variables but I get the error "This value must be a scalar or a matrix". Please see the attachment.
Thanks
As Fred say, you can't add range variables. A range variable is an implied iterator - it provided the major form of iteration in the early versions of Mathcad before programming was added to provide the for loop.
A range variable is quite distinct from a vector. A vector is a one-column array in Mathcad whereas a range variable is a variable that holds a range, a specialized data type of the form "start,next..end". You can't perform arithmetic on this data type, hence you can't add them together. Whenever Mathcad encounters a range variable in an expression it automatically iterates over each of the values obtained by expanding the range. When Mathcad encounters a vector (or other array) it operates on the vector as a whole.
To allow me to make better use of range variables I created a general purpose function called vec that will convert a range variable into a vector - see attached worksheet for it application to your worksheet.
Stuart
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.