The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Vectors in Origin

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
HelpMePlease Posted - 08/24/2014 : 4:57:22 PM
I'm using origin 9.0 and have found myself in a situation where I need to use something like vector.push_back() function (as with normal c/c++). Am I missing something or is there no support for a function like this in origin? I've looked at the header file but haven't been able to find a useful alternative. Is there a way to at least dynamically allocate space for a vector so as to avoid using the SetSize() function?

Not having something like this seems to defeat the whole point of using vectors! We might as well just use arrays (which can't be avoided in origin since most arguments for data objects take in vectors).

Thanks in advance for any advice/help!

2   L A T E S T    R E P L I E S    (Newest First)
HelpMePlease Posted - 08/25/2014 : 9:18:15 PM
Ah this is exactly what i needed.


Thanks so much!

Using Origin 9
jasonzhao Posted - 08/25/2014 : 06:28:57 AM
Hello,

You can refer to http://www.originlab.com/doc/OriginC/ref/vector and http://www.originlab.com/doc/OriginC/ref/vector-Add which can construct a dynamically allocated and sized array.

The following examples shows the way to assign data to a column by Vector and add extra elements to it.

#include <Origin.h>
void main()
{
Worksheet wks;
wks.Create("Origin");

 		

vector<double> vX(10);           // vX has 10 elements
for(int ii = 0; ii < 10; ii++)
        vX[ii] = ii;
for(int jj = 0; jj < 10; jj++)  // add extra 10 elements
    {double d = jj; 
      vX.Add(d);}

 Dataset dsA;   // Create Origin C Dataset		
dsA.Attach(wks,0); // Attach Origin C Dataset object dsA to Origin data set wks(0)	

dsA=vX;
}


Best regards,
Jason Zhao
OriginLab Tech Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000