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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

vectorization - I need to change an array into vector in Prime 10

YA_10963798
14-Alexandrite

vectorization - I need to change an array into vector in Prime 10

Hi everyone,

I need to change an array into vector in Prime 10 .  

@StuartBruff ..Stuart you have previously suggested this method , but I don't know where I have a mistake 
 
.
YA_10963798_1-1731927867903.png

Can you show me how to solve this? Prime 10 is attached 

 

Thanks in advance 
 
 
ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:YA_10963798)

Terry already pointed you to the missing assignment.

But the first, simpler version of "vec" you show in your picture should work equally well!

Stuarts version has the benefit that it also unravels recursively nested vectors. But thats not necessary when you just want to turn a range into a vector. You also should not keep both versions of "vec" with the same name in your sheet. The call of "vec" in the "stack" function of the second "vec" variant would call the first variant and not itself as it should be. Thats the reason I renamed Stuarts function to "vec2" in the picture below which is just here to demonstrate what Stuarts function is capable of:

Werner_E_0-1731943098377.png

The simple "vec" is only good for turning a range into a vector.

Stuarts extended version will also deal with nested matrices.

It will not deal with matrices containing ranges, though 😉 😈

Werner_E_1-1731942616602.png

Dealing with this moloch, too, would make it necessary to add Stuarts "IsRange" function alongside the "IsArray".

 

View solution in original post

7 REPLIES 7

Z is already a vector not a range. 

Capture.JPG

Cheers

Terry

Hi Terry,

Thank you for replying .. actually this is the original sheet 

YA_10963798_0-1731929809025.png

and it tells me I need to have ztips as vector 

YA_10963798_1-1731929844428.png

the above sheet was a simplified sheet to explain what I need to do ..

Capture.JPG

Thank you Terry that was helpful 

Werner_E
25-Diamond I
(To:YA_10963798)

Terry already pointed you to the missing assignment.

But the first, simpler version of "vec" you show in your picture should work equally well!

Stuarts version has the benefit that it also unravels recursively nested vectors. But thats not necessary when you just want to turn a range into a vector. You also should not keep both versions of "vec" with the same name in your sheet. The call of "vec" in the "stack" function of the second "vec" variant would call the first variant and not itself as it should be. Thats the reason I renamed Stuarts function to "vec2" in the picture below which is just here to demonstrate what Stuarts function is capable of:

Werner_E_0-1731943098377.png

The simple "vec" is only good for turning a range into a vector.

Stuarts extended version will also deal with nested matrices.

It will not deal with matrices containing ranges, though 😉 😈

Werner_E_1-1731942616602.png

Dealing with this moloch, too, would make it necessary to add Stuarts "IsRange" function alongside the "IsArray".

 

YA_10963798
14-Alexandrite
(To:Werner_E)

Thank you Werner .. Always an answer with thorogh explaination. 

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Terry already pointed you to the missing assignment.

But the first, simpler version of "vec" you show in your picture should work equally well!

Stuarts version has the benefit that it also unravels recursively nested vectors. But thats not necessary when you just want to turn a range into a vector. You also should not keep both versions of "vec" with the same name in your sheet. The call of "vec" in the "stack" function of the second "vec" variant would call the first variant and not itself as it should be. Thats the reason I renamed Stuarts function to "vec2" in the picture below which is just here to demonstrate what Stuarts function is capable of:

Werner_E_0-1731943098377.png

The simple "vec" is only good for turning a range into a vector.

Stuarts extended version will also deal with nested matrices.

It will not deal with matrices containing ranges, though 😉 😈

Werner_E_1-1731942616602.png

Dealing with this moloch, too, would make it necessary to add Stuarts "IsRange" function alongside the "IsArray".


 

Not necessary, because IsRange itself is defined in terms of existing types, but certainly jolly useful.   By one of those serendipitous coincidences, I included a range-expanding version of vec a few weeks ago when I was creating a new Library function worksheet that deals with ranges.  I usually use a version of vec that treats strings as vectors-in-waiting ... saves me having to remember what I called str2chr ... but there are also occasions when I want the string returned and it probably won't suit most people's needs.   So,  here are vec and vecs:

 

2024 11 19 B.png

 

Stuart

Announcements

Top Tags