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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to turn a column vector into a line vector when the number was defined as a sequence?

Cornel
18-Opal

How to turn a column vector into a line vector when the number was defined as a sequence?

Hello,

Cornel_0-1690967594269.png

Cornel_1-1690967600713.png

Cornel_2-1690967607706.png


How to turn this column vector intro a line vector (like shown below)?

Cornel_3-1690967692787.png

Cornel_1-1690967996181.png

 

Mathcad Prime 8 file attached.

1 ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:Cornel)

8 REPLIES 8
ttokoro
20-Turquoise
(To:Cornel)

image.pngimage.png

Cornel_0-1690968734549.png

Cornel_1-1690968740555.png

Cornel_2-1690968763180.png

How to deal with this comment in green?

 

Cornel_3-1690968780342.png

Cornel_4-1690968787002.png

LucMeekes
23-Emerald III
(To:Cornel)

In this case, you accept it, because you do redefine the vector d purposely.

It's just a warning, not an error.

 

Success!
Luc

LucMeekes
23-Emerald III
(To:Cornel)

You do that with the transpose operator, like you did.

But you have to do it on the vector, not on a range.

the vector is a, not an.

So remove that [n from a under the transpose and it works.

 

Explanation:

You created the vector a in a neat, regular, legal way, using the range n.

To show the vector a, all you need to do is type

a=

and it will show the column vector.

You typed

an=

which appears to show the same, but Prime interprets as something else. It takes the vector a, and apples the range n, and displays for each of the values of the range n, the corresponding element of a. And the displayed result looks just the same as when it shows the vector a.

 

Success!
Luc

 

Werner_E
24-Ruby V
(To:Cornel)

According row vector:

Werner_E_0-1690970801207.png

 

 

According the green redefinition warning:

It appears because you are changing the value of "d". As this is exactly what you intend, you may ignore that warning.

You may also consider turning off these warnings

Werner_E_1-1690971001047.png

 

Cornel_0-1690974504878.png

Cornel_1-1690974511405.png

 

Case 1:

Cornel_2-1690974565364.png

Cornel_3-1690974584032.png

 

Case 2:

Cornel_4-1690974601677.png

Cornel_5-1690974622297.png

According to calculation:

Cornel_7-1690974837931.png

So, I need to put ORIGIN=1 in order for first element to be equal with 2, with the real a1 value, even that I defined n = 1, 2...10, so the first element of n is 1. Why is this difference?

 

EDIT:

Cornel_1-1690975539808.png

Cornel_0-1690975530154.png

Cornel_2-1690975546802.png

Cornel_3-1690975558200.png

Werner_E
24-Ruby V
(To:Cornel)

An ORIGIN-independent approach to create a vector with the first 10 values:

Werner_E_1-1690977911775.png

 

or a different approach using a vector n:

Werner_E_3-1690978281830.png

Using explicit vectorization is not mandatory in this case, but might be in case of different calculations.

 

Of course you can also turn the range into a vector using that undocumented trick with the inline evaluation:

Werner_E_0-1690979859981.png

 

 

 

 

LucMeekes
23-Emerald III
(To:Cornel)

"So, I need to put ORIGIN=1 in order for first element to be equal with 2, with the real a1 value, even that I defined n = 1, 2...10, so the first element of n is 1. Why is this difference?"

 

When you define a range:

n := 1,2..10

you define sort of a counter, that counts from 1 to 10.

You can use it to create vector elements, by using n as the index, to point to individual vector elements.

So when you assign

an := 3+(-1)^n

you first assign a1, then a2, and so further until a10.

but if ORIGIN=0, then the very first element of every vector will be the one with index 0, so a0, is created (automatically) when a1 is created.

In short, your definition of a range that you use to fill vector elements is independent of ORIGIN, the index of the first element of the array.

If ORIGIN=2, then your range for n will cause an error at the assignment an := 3+(-1)^n, simply because  a1 cannot exist. With ORIGIN=2, the first element of the array is a2.

Hope this helps.

 

Success!
Luc

Top Tags