Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

This value must be a scalar or a matrix - Mathcad Prime 10 issue

JB_10745469
4-Participant

This value must be a scalar or a matrix - Mathcad Prime 10 issue

Hi,

 

I am getting the following issue on Mathcad 10:

 

"This value must be a scalar or a matrix"

 

I am looking to define the output matrix as β. It seems to work on its own but not when I try and assign it as β.

JB_10745469_1-1737562549368.png

It isn't an issue when run on Mathcad Prime 8 or 9.

 

Help would be appreciated.

 

Thanks

17 REPLIES 17
StuartBruff
23-Emerald III
(To:JB_10745469)

The behaviour of the evaluation operator (=) changed in Mathcad Prime 10.

 

Previously, when defining a range, using the = operator converted the range into a vector.  In Mathcad 10 it no longer does so; hence the error message when you try to use n.

 

You will have to explicitly define n as a vector, or create a function to convert a range variable to a vector.  Try the vec function defined in this link:

 

https://community.ptc.com/t5/Mathcad/The-vec-function/td-p/170273

 

Stuart

You should not use a range - use n as a vector !

 

regards Owe

Werner_E
25-Diamond I
(To:o.svahn)

Looks like you attached the wrong file - its the same as the original posted one.

o.svahn
12-Amethyst
(To:Werner_E)

Sorry Werner_E

 

here it is !

 

Werner_E
25-Diamond I
(To:JB_10745469)

Stuart already explained why this problem occurs in P10 and how to solve it.

Inline evaluation does not convert a range into a vector starting with Prime 10. So even though you use inline eval, n remains to be a range and so the assignment to variable beta fails.

PTC's decision to make the (admittedly illogical and inconsistent) option of converting a range to a vector impossible without providing a more sensible inbuilt alternative is regrettable.

 

In case you are still unsure here your file in a working variant.

I used a simpler variant of a range-to-vector function, for more capable and sophisticated versions follow Stuart link.

Werner_E_0-1737571898653.png

Of course you could also define n as a vector right away. Either using a  global range variable

Werner_E_2-1737572039576.png

or using a programmed for-loop

Werner_E_3-1737572083853.png

 

In some threads in this forum you will also find user-defined functions to create a vector by providing first, second and last value (similar to the definition of a range) or also by providing first value, step value and either last value or number of entries.

 

 

 

 

 

LucMeekes
23-Emerald III
(To:Werner_E)

I should like to add a more concise method to create a simple vector with successive values:

LucMeekes_0-1737578189306.png

(The matrix function creates a vector (5 elements vertical, one column in the above case), with values 0, 1, 2... then 2 is added;. the inline evaluation is not necessary, but used here to show the expression creates the correct vector.)

Success!
Luc

Cornel
19-Tanzanite
(To:Werner_E)


@Werner_E wrote:

Stuart already explained why this problem occurs in P10 and how to solve it.

Inline evaluation does not convert a range into a vector starting with Prime 10. So even though you use inline eval, n remains to be a range and so the assignment to variable beta fails.

PTC's decision to make the (admittedly illogical and inconsistent) option of converting a range to a vector impossible without providing a more sensible inbuilt alternative is regrettable.


@DJNewman Is it not possible to take this question and tell to the Mathcad development team to restore again somehow the working of the inline evaluation which converts range into a vector?

DJNewman
17-Peridot
(To:Cornel)

Mathcad Prime 11 will have the built-in alternative function.

 

The Mathcad team considered that (permanently) converting from one data type into a data type by in-line evaluating it to be a bug. Which, from a programmer's point of view, is correct. From a user's point of view, this is desirable behaviour and that's why people did this to begin with.

But that's why they are making a built-in function for it for the next release to address that gap. Would it have been better to address that gap back in 10.0.0.0? Yes.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
LucMeekes
23-Emerald III
(To:DJNewman)

Oh, I was thinking back in 1.0.0.0...

 

Luc

StuartBruff
23-Emerald III
(To:LucMeekes)

Heck, I was thinking Mathsoft Mathcad 11 … 😎

 

The vec (ravel/whatever) function must surely be at least Mathcad 7/8/2000 vintage, and the range-vector distinction/conversion problem has been confusing/annoying people for a very long time.

 

Stuart

 

Anyway, I’m digging out the popcorn whilst listening to Storm Eowyn beginning to sing its song. Only about 60 mph at the moment with some much stronger gusts. 

Cornel
19-Tanzanite
(To:DJNewman)

Do You have any idea when Mathcad Prime engine will be as powerfull as Maple or Wolfram engine in terms of symbolics (it's a lack here) and numerics?

DJNewman
17-Peridot
(To:Cornel)

It's not in our roadmap to swap out engines yet again (a very time-consuming, multi-year process), but it continues to be a focus area to improve the engines we already have.

I manage the Creo and PTC Mathcad YouTube channels for PTC, as well as all PTC Mathcad marketing in general.
Cornel
19-Tanzanite
(To:DJNewman)

Maybe it's not about to swap the engine, but to make more powerful the Mathcad engine from now. I am wondering why the engine used by Mathcad cannot be as powerfull as Maple or Wolfram engine in terms of symbolics calculations(here it's still weak) and even numeric calculations (although for numerical calculations it is quite ok (If the numerics are not so large), for more powerful numerical calculations or longer numerical calculation sheets it works slowly and hard))?

Werner_E
25-Diamond I
(To:DJNewman)


@DJNewman wrote:

Mathcad Prime 11 will have the built-in alternative function.

 

The Mathcad team considered that (permanently) converting from one data type into a data type by in-line evaluating it to be a bug. Which, from a programmer's point of view, is correct. From a user's point of view, this is desirable behaviour and that's why people did this to begin with.

But that's why they are making a built-in function for it for the next release to address that gap. Would it have been better to address that gap back in 10.0.0.0? Yes.


I tend to agree that this undocumented trick was illogical and I can understand that this rather unexpected type conversion by a simple evaluation can be considered a bug. I just would have wished that the official type conversion function would have been presented in Version n with the announcement, that the unofficial way will not work starting with version n+1.

Hope we can use the new function in Prime 11 directly like v := vec(2,4..9) to get the vector [2; 4; 6; 8]  without having to define a range variable in first place.

LucMeekes
23-Emerald III
(To:Werner_E)

And I would hope that the function

IsRange()

Is also implemented.

 

Luc

StuartBruff
23-Emerald III
(To:LucMeekes)

Definitely.  

The numeric IsInteger also needs fixing. It has far too limited a definition of what an integer is.

 

Stuart

 

Storm Eowyn is seemingly blowing at about 85 mph where I am, and gusting quite nicely on top of it. Sadly, my anemometer can’t handle anything above 55 mph, so I’m having to rely on the Met Office.

StuartBruff
23-Emerald III
(To:Werner_E)

would also like this capability back, as well as the ability to define arbitrary sequences in a for-loop’s iteration expression.

 

In fact, what id really like is a Sequence data type that would allow this latter capability and provide the argument list for functions. That should allow for arbitrary-length arguments, a very long-standing feature request.

 

From a UI point of view, the prime(!) blocker to getting vec(2,4..9) is the use of “,” to act as the 3-place range operator at worksheet level and as a term separator within parentheses- unlike Mathsoft Mathcad.

 

Stuart

Announcements

Top Tags