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

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

must be scalar

YA_10963798
14-Alexandrite

must be scalar

Hi there, 

I think almost 30% of mathcad's community questions is about ( this value must be scalar) .. I really find it confusing to differentiate between scalar/ array/ vector( maybe it seems stupid to you, but can you tell me how to identify each one of them? and the errors occur because of them

I got this error in my sheet, how can I solve it ?

YA_10963798_0-1732092292059.png

prime 10 is attached

Thanks in advance

 

ACCEPTED SOLUTION

Accepted Solutions

Hi,

Like this:

Capture.JPG

Scalar is an individual value like a:=3

range is a group of values i:=1,2..5.  You can tell a range from a vector because you cannot subscript one of the group i[2 does not exist

vector is a mathematical construct.  you can tell a vector from a range as you can subscript an individual scalar from the vector b:=v[2

Cheers

Terry

 

View solution in original post

4 REPLIES 4

Hi,

Like this:

Capture.JPG

Scalar is an individual value like a:=3

range is a group of values i:=1,2..5.  You can tell a range from a vector because you cannot subscript one of the group i[2 does not exist

vector is a mathematical construct.  you can tell a vector from a range as you can subscript an individual scalar from the vector b:=v[2

Cheers

Terry

 

thank you so much terry 

Werner_E
25-Diamond I
(To:YA_10963798)

Just to explain the error message:

 

It stems from the line   if Layer[j <-- "Sand"

 

The if-statement must be followed by a real number, a scalar. If its 0 its interpreted as "false", all other values as "true".

A comparison like a=b returns 0 or 1, depending on the values in a.

But a local assignment like x <--- abc  'returns' the value abc.

You accidentally used an assignment and not as you were supposed to do a comparison. And you assigned a string ("Sand").
So your if-statement reads if "Sand" ... and thats syntactically wrong as Prime expects a number, a scalar for which it can decide if its zero or not where you provided a string, a text.

The error had nothing to do with ranges vs vectors and it also had nothing to do with the vectorization you applied. This vectorization is not necessary as all involved variables are scalars and not vectors, but it would not do any harm.

Another error in your routine were the indices which Terry has fixed as well. Your original would have run into a "index out of range/invalid index" error because sigma'.v contains more elements than Layer.

BTW, writing nfs[j after the if/else statement has no effect and you could delete this line.

YA_10963798
14-Alexandrite
(To:Werner_E)

AAh I understand now . If you notice in my previous questions I always get stuck in such error .. either ( this value must be a scalar or this value must be a vector) so I thought there are many things should be learnt to overcome this error, but it seems each error has its own reason ..

Thank you for the clarification 

Announcements

Top Tags