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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Must be a scalar or a matrix

yeet
1-Visitor

Must be a scalar or a matrix

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

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:yeet)

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

View solution in original post

2 REPLIES 2
Fred_Kohlhepp
23-Emerald I
(To:yeet)

You can't add range variables. They work for plotting or for indices of vectors or matrices but they're not vectors so you can't operate on them.

StuartBruff
23-Emerald III
(To:yeet)

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

Announcements

Top Tags