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
 dynamic array worksheet

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
g.statkute Posted - 07/29/2008 : 05:46:06 AM
Hello,

1)How to allocate memory dynamically for 2D array in Origin, i get "general compiler error"?
2)How to paste elements of array to a new worksheet with OriginC?
3)Is it possible to write a part of code in labTalk and use it in *.cpp file?


void DefaultSmooth() {
	
	Worksheet wks = Project.ActiveLayer();
	if(!wks) {
		out_str("no acitve workbook window to import data");
		return;
	}
	
	int RowNo = wks.GetNumRows();
	int daliklis=1;
	int n,m;
	//double m2,m1,m,p1,p2,tarp,diff;
	
	
	//memory allocation for arrays
	double v1=-70000000, v2=70000000;
	double * Gpoints, Bpoints, Fpoints;
	Gpoints=(double *)malloc(v1*v2*sizeof(double));
	Bpoints=(double *)malloc(v1*v2*sizeof(double));
	Fpoints=(double *)malloc(v1*v2*sizeof(double));

	for(m=0;m<RowNo;m++){
		for(n=0;n<2;n++){
			//printf("Enter array elements:");
			Gpoints[n][m])=0;
			Bpoints[n][m])=0;
			Fpoints[n][m])=0;
		}
	}
//some code for data manipulation,
//how to pasta data from final array Fpoints to the worksheet?
}
1   L A T E S T    R E P L I E S    (Newest First)
Iris_Bai Posted - 07/30/2008 : 06:06:28 AM
1)We don't support 2D array in OriginC since we have matrix, so you can use matrix to do the job.
2)We can use GetColumn or GetRow of matrix to get a column or a row as a vector, and then put it into Worksheet.
3)We can use LT_execute. Just like LT_execute( strCmd );

void example()
{
	//1)
	int v1=3,v2=2;
	matrix<int> m(v1,v2);    //a array of int sized v1*v2
	int ii,jj;
	for(ii=0;ii<v1;ii++)
		for(jj=0;jj<v2;jj++)
			m[ii][jj] = ii+jj;
	for(ii=0;ii<v1;ii++)
	{
		for(jj=0;jj<v2;jj++)
			printf("%d ", m[ii][jj]);
		printf("\n");
	}

	//2)
	Worksheet wks;
	wks.Create("Origin");   //new a worksheet
	Dataset ds;
	for(ii=0;ii<v2;ii++)
	{
		ds.Attach(wks,ii);   //ds is attach to the iith column of wks, ii begins from 0
		m.GetColumn( ds, ii );//get data of the iith column, and the data will be shown at the worksheet
	}
}


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