Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi,
Can you help me in solving this equation? I'm stock in this equation. I am using Mathcad Prime 10. And the error is said to be "This value must be a scalar or a matrix".
Solved! Go to Solution.
No, you are NOT using Prime 10 but rather Prime 11 !! At least the sheet you attached was saved with Prime 11.
You are not the first and sure not alone with the problem.
The confusion about ranges versus vectors exists since Mathcad exists.
The reason for the error message you get is because what you created as "v" is NOT a vector but rather a range variable.
You may look at a range as an implicit for loop, not as a list of specific values.
You may display C*v^alpha but actually its an invalid data type - its not a range and its not a vector either. So Prime refuses to assign it the variable F.
Ranges should be used for nothing else but
1) index the elements of vectors and matrices
2) create for-loops in programs
3) define the abscissa values when you plot a function
So the solution is to create "v" as a vector. You could use one of the "range_to_vector" programs which were posted here in the forum from time to time to convert the range you created into a vector.
Or you could create "v" as a vector right ahead using a range ("i") just to index the vector elements similar to what Terry had shown.
But the simplest way is to use the "vec" function which exists since Prime 11 and uses a similar syntax as the definition of ranges (it could also be used to convert ranges to vectors - look it up in the help).
Now the creation of F should work and I consider it good style to explicitly apply vectorization rather than relying on Primes implicit auto-vectorization:
The creation of vector BL still will fail. Reason is that you cannot compare a vector (v) with a scalar (v.r) and vectorization does not help here because the comparison operators are implemented in a way so they can not be vectorized directly.
You have a couple of options to create BL.
.) ttokoro defined a function which then can be called vectorized to create the vector BL
.) Terry used his range variable to create the vector element by element
.) you can also use a small programmed for-loop which basically does the same but without using a global range variable
I used the (Excel-like) if-function instead of the programmed if-statement just to save vertical space. But I would agree on that the if-statement is more clear to read.
Whatever way to create vector BL you prefer to use, now you can plot the vectors F and BL over the vector v.
But actually I wonder why you tried to create vectors for v, F and BL anyway. If all you want to achieve is to plot the two functions, then simply define functions. Prime is thankfully not a spreadsheet like Calc or Excel and it is therefore not at all necessary to create vectors in order to plot a function!
and let Prime plot them:
In this picture I used the undefined(!) variable "v" at the abscissa and Prime automatically choses a range from -10 to 10 for it. That's not what you need.
At each axis you can edit the first, second and last value and I did so at the abscissa in the next picture (i changed the three highlighted values. I did not type "30" but rather "v.m", so changing v.m at the top would be automatically reflected by the plot.
As explained above you can (maybe should, because it gives better control) use a range variable for the abscissa. Here the limits on the abscissa are automatically chosen accordingly - you may have to edit the second value (here the "3") because Prime usually divides in 10 intervals which may not be always desired.
Prime 11 sheet attached
Hi,
Confused as the worksheet could not be opened in version 10, has to use version 11?
A range variable is created like "iv" (index into vector "v")
One way a vector is created using "iv" index into "vvector"
In Prime 11 you can use the new vec() function to turn a range into a vector.
They open it in Prime 11.
No, you are NOT using Prime 10 but rather Prime 11 !! At least the sheet you attached was saved with Prime 11.
You are not the first and sure not alone with the problem.
The confusion about ranges versus vectors exists since Mathcad exists.
The reason for the error message you get is because what you created as "v" is NOT a vector but rather a range variable.
You may look at a range as an implicit for loop, not as a list of specific values.
You may display C*v^alpha but actually its an invalid data type - its not a range and its not a vector either. So Prime refuses to assign it the variable F.
Ranges should be used for nothing else but
1) index the elements of vectors and matrices
2) create for-loops in programs
3) define the abscissa values when you plot a function
So the solution is to create "v" as a vector. You could use one of the "range_to_vector" programs which were posted here in the forum from time to time to convert the range you created into a vector.
Or you could create "v" as a vector right ahead using a range ("i") just to index the vector elements similar to what Terry had shown.
But the simplest way is to use the "vec" function which exists since Prime 11 and uses a similar syntax as the definition of ranges (it could also be used to convert ranges to vectors - look it up in the help).
Now the creation of F should work and I consider it good style to explicitly apply vectorization rather than relying on Primes implicit auto-vectorization:
The creation of vector BL still will fail. Reason is that you cannot compare a vector (v) with a scalar (v.r) and vectorization does not help here because the comparison operators are implemented in a way so they can not be vectorized directly.
You have a couple of options to create BL.
.) ttokoro defined a function which then can be called vectorized to create the vector BL
.) Terry used his range variable to create the vector element by element
.) you can also use a small programmed for-loop which basically does the same but without using a global range variable
I used the (Excel-like) if-function instead of the programmed if-statement just to save vertical space. But I would agree on that the if-statement is more clear to read.
Whatever way to create vector BL you prefer to use, now you can plot the vectors F and BL over the vector v.
But actually I wonder why you tried to create vectors for v, F and BL anyway. If all you want to achieve is to plot the two functions, then simply define functions. Prime is thankfully not a spreadsheet like Calc or Excel and it is therefore not at all necessary to create vectors in order to plot a function!
and let Prime plot them:
In this picture I used the undefined(!) variable "v" at the abscissa and Prime automatically choses a range from -10 to 10 for it. That's not what you need.
At each axis you can edit the first, second and last value and I did so at the abscissa in the next picture (i changed the three highlighted values. I did not type "30" but rather "v.m", so changing v.m at the top would be automatically reflected by the plot.
As explained above you can (maybe should, because it gives better control) use a range variable for the abscissa. Here the limits on the abscissa are automatically chosen accordingly - you may have to edit the second value (here the "3") because Prime usually divides in 10 intervals which may not be always desired.
Prime 11 sheet attached