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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Concept of vectors in a matrix and their plotting

MUFASA
6-Contributor

Concept of vectors in a matrix and their plotting

I am facing a problem and can't figure out what is going on. I have seen previous posts on the community but not able to grasp the concept of vectors. Please, someone, explain the difference in clear terms so that nothing remains ambiguous.

The first problem is I am trying to return two vectors in a 1x2 vector. This means it will be a nested vector. I have seen some posts where it is done but when I try to do it, it gives the dimension of a vector rather than the vector itself. Of course, the problems resolve when I use the augment command but I want to know why it is not printing the vector.

1.png

In the below figure (obtain from the community) the D shows the vector elements but when I try to display it again, it display the size of the vector 😫

2.png
Similarly, the second problem is that when I try to plot vectors it says, "These array elements must be scalar. They cannot be vectors or matrices". But when I search the community there were examples where these plots were made. So, I am confused 😕
3.png

Here is the example where such plots were made.

4.png

Mathcad Prime 7 files are attached

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:MUFASA)

To see the real contents of nested matrices rather than just the dimensions, you have to uncheck "Collapse Nested Matrices" on the "Matrices/Tables" tab.

Werner_E_0-1618951384466.png

 

According your plotting problem you must be aware, that your variable "days" is not a vector but a range. Unfortunately ranges and vectors look the same when you display them.
A range is sort of an implicit loop and should be used for

1) index the elements of vectors and matrices
2) define the plot range of a 2D-plot when you plot functions
3) a for-loop in a Mathcad program

and thats all.

To define "days" as a vector you may do it as follows:

Werner_E_1-1618952154954.png

Note that you have to use the vector index and not the literal index here.

You may also use a convenient undocumented (and unsupported) trick to turn a range into a vector:

Werner_E_3-1618952279981.png

The evaluation (=) immediately after the definition turns the range into a vector.

 

In this forum from time to time functions to create a vector were posted which you could use if you need to do it often. Here is a variant which follows the syntax of the range definition - you have to provide the first, second and last value in your vector. As usual in a range, the last value must not be necessarily part of the vector. In contrary to a range definition this function does not allow to omit the second value.

Werner_E_4-1618952857137.png

 

And if you don't like the trick with the inline evaluation, you may use a function to turn a range into a vector

Werner_E_5-1618953185889.png

 

 

 

 

 

View solution in original post

3 REPLIES 3
MUFASA
6-Contributor
(To:MUFASA)

In the previous files that were attached, the changes were not saved. I have updated the files where the necessary changes that I do have been saved.

Werner_E
24-Ruby V
(To:MUFASA)

To see the real contents of nested matrices rather than just the dimensions, you have to uncheck "Collapse Nested Matrices" on the "Matrices/Tables" tab.

Werner_E_0-1618951384466.png

 

According your plotting problem you must be aware, that your variable "days" is not a vector but a range. Unfortunately ranges and vectors look the same when you display them.
A range is sort of an implicit loop and should be used for

1) index the elements of vectors and matrices
2) define the plot range of a 2D-plot when you plot functions
3) a for-loop in a Mathcad program

and thats all.

To define "days" as a vector you may do it as follows:

Werner_E_1-1618952154954.png

Note that you have to use the vector index and not the literal index here.

You may also use a convenient undocumented (and unsupported) trick to turn a range into a vector:

Werner_E_3-1618952279981.png

The evaluation (=) immediately after the definition turns the range into a vector.

 

In this forum from time to time functions to create a vector were posted which you could use if you need to do it often. Here is a variant which follows the syntax of the range definition - you have to provide the first, second and last value in your vector. As usual in a range, the last value must not be necessarily part of the vector. In contrary to a range definition this function does not allow to omit the second value.

Werner_E_4-1618952857137.png

 

And if you don't like the trick with the inline evaluation, you may use a function to turn a range into a vector

Werner_E_5-1618953185889.png

 

 

 

 

 

ttokoro
20-Turquoise
(To:MUFASA)

image.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png

Top Tags