HP Prime: adding an entry to a vector « Next Oldest | Next Newest »

 ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 12-01-2013, 01:04 PM Hi, How do you add an entry to a vector (like going from [1,2] to [1,2,3])? ADDCOL for matrices does not work for vectors because (row) vectors are not matrices for the Prime (a matrix has at least 2 rows). And even if ADDCOL worked, it would not add an entry at the end of the vector. Thank you! Edited: 1 Dec 2013, 2:09 p.m. after one or more responses were posted ▼ Terje Vallestad Junior Member Posts: 24 Threads: 2 Joined: Sep 2011 12-01-2013, 01:56 PM I think append will do it Example: append([1,2,3],4) gives [1,2,3,4] Cheers, Terje ▼ cyrille de Brébisson Member Posts: 193 Threads: 10 Joined: Mar 2008 12-02-2013, 03:05 AM ADDROW(vector, value, column) will do what you want... cyrille ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 12-02-2013, 10:02 AM Thanks Terje and Cyrille, APPEND does what I wanted, ADDROW does not seem to work ADDROW([1,2],3,3) results in error. Same with ADDCOL. ▼ Terje Vallestad Junior Member Posts: 24 Threads: 2 Joined: Sep 2011 12-02-2013, 11:22 AM Hi, From exprimentation and seeing other similar issues by others On this forum I think you need to enclose the 3 in tickmarks. I.e. ADDROW([1,2],'3',3) results in [1,2,3] ADDCOL([1,2],'3',3) also results in [1,2,3] Cheers, Terje ▼ Michael de Estrada Posting Freak Posts: 1,665 Threads: 142 Joined: Jan 2009 12-02-2013, 11:42 AM What I've found is that you can't use matrix operations on a vector. A vector is designated by a single set of square brackets, e.g. [1,2,3], whereas a single row matrix will be [[1,2,3]]. If you do Shift 4 (Matrix), you will see the vector appear as dimension 3, whereas the matrix will appear as 1X3. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 12-02-2013, 12:12 PM Yes, a matrix in the prime must have at least 2 rows, according to the user guide. The commands ADDCOL([1,2],'3',3) do not seem to work for me. Thanks. ▼ Michael de Estrada Posting Freak Posts: 1,665 Threads: 142 Joined: Jan 2009 12-02-2013, 12:23 PM It doesn't need two rows; it just needs two separate dimensions. So if you have a vector v:=[1,2,3], then v(2) would return 2, whereas in a matrix m:=[[1,2,3]], m(1,2) would return 2. Edited: 2 Dec 2013, 1:54 p.m. Terje Vallestad Junior Member Posts: 24 Threads: 2 Joined: Sep 2011 12-02-2013, 12:23 PM Hi, I got it to work in Home, not in CAS Cheers, Terje ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 12-02-2013, 12:27 PM Ok, yes, it does work in Home. I was in CAS. thanks. Terje Vallestad Junior Member Posts: 24 Threads: 2 Joined: Sep 2011 12-02-2013, 12:21 PM Hi, I think you will find if you try using the additional argument enclosed in tick marks, you keep the vector format in the result even if you are using matrix commands Cheers, Terje ▼ Michael de Estrada Posting Freak Posts: 1,665 Threads: 142 Joined: Jan 2009 12-02-2013, 12:37 PM But why go to all this trouble ? If you just stick with matrix form throughout, everything works fine and can be done in both Home and CAS view. Just like whenever I use CAS operations inside programs, which is basically the same as Home view, then I just place them inside a CAS(" ") command. Edited: 2 Dec 2013, 12:37 p.m. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 12-02-2013, 01:18 PM Oh well, now I got it! This works ADDCOL([[1,2]],[3],3) gives [1,2,3] in CAS. Thank you all!

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime - vector question bluesun08 3 976 11-18-2013, 07:26 PM Last Post: Han Complex Number Entry on Prime Jeff O. 19 2,979 11-16-2013, 12:34 PM Last Post: Jeff O. [HP-Prime CAS] Vector Calculus Library CompSystems 7 1,588 10-31-2013, 12:48 PM Last Post: Han Program to change entry mode on Prime Michael de Estrada 3 996 10-28-2013, 10:13 AM Last Post: Han HP-Prime/Xcas: vector/list indexing fhub 6 1,492 10-27-2013, 04:52 PM Last Post: fhub Does RPN entry mode cause the Prime keyboard to lock up ? Michael de Estrada 14 2,590 10-22-2013, 06:27 PM Last Post: John Colvin HP Prime: Vector field CURL(). How-to... Chris Tvergard 4 1,002 09-26-2013, 03:55 PM Last Post: Chris Tvergard WP-34S: Program for vector (3D) manipulation Marcel Samek 4 1,063 09-05-2013, 05:29 AM Last Post: Marcus von Cube, Germany [HP-Prime CAS] list[x,y,z], vector[x, y, z ] ... data type operation? CompSystems 1 710 08-22-2013, 03:30 PM Last Post: Joe Horn [HP -Prime CAS] List, Matrix, Vector as one Array? CompSystems 0 549 07-26-2013, 05:22 PM Last Post: CompSystems

Forum Jump: