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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 importing data in matrix
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

elena_loginova

USA
Posts

Posted - 12/09/2009 :  9:56:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Pro 8 SR 6, Windows XP

Hi,

I need help in importing one column into the matrix with dimensions n x m. Could anybody please help me with a script or with a one-time procedure? I cannot find this information anywhere. Thank you in advance. Elena.

larry_lan

China
Posts

Posted - 12/10/2009 :  10:32:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Elena:

The following script is a simple example to put data from one column into a n by m matrix.

// Supposed source data in column 1 of sheet1, book1
// and target matrix is the first matrix in mbook1, msheet1
range rw = [book1]sheet1!col(1);
range rm = [mbook1]msheet1!mat(1);

n = 3; // matrix row
m = 2; // matrix column

for(int ii = 1; ii <= n; ii++)
{
	for(int jj = 1; jj <= m; jj++)
	{
		rm[ii, jj] = rw[(ii-1)*m + jj];
	}
}

Please change the script as you need. In the script, we use ranges to access different Origin objects. Maybe you can start reading from the range notation charpter in our LabTalk Guide to know how to write such scripts?

Thanks
Larry

Edited by - larry_lan on 12/10/2009 10:34:25 AM
Go to Top of Page

elena_loginova

USA
Posts

Posted - 12/11/2009 :  11:43:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, Larry! It works! I appreciate your fast response.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000