This value must be a scalar or a matrix - Mathcad Prime 10 issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 β.
It isn't an issue when run on Mathcad Prime 8 or 9.
Help would be appreciated.
Thanks
- Labels:
-
Mathcad Usage
-
Mechanical_Engineering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You should not use a range - use n as a vector !
regards Owe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Looks like you attached the wrong file - its the same as the original posted one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Of course you could also define n as a vector right away. Either using a global range variable
or using a programmed for-loop
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I should like to add a more concise method to create a simple vector with successive values:
(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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Oh, I was thinking back in 1.0.0.0...
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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))?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
And I would hope that the function
IsRange()
Is also implemented.
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I 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
