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
 Origin Forum
 problem importing mat files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rockyraccoon

8 Posts

Posted - 09/10/2009 :  09:07:18 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,
I have several hundreds .mat (MATLAB) files which contain just 6 variables.
The import of single files works fine. Importing multiple files however results in the creation of as many books as files. Obviously this is not very convenient.
I would rather have Origin import each file as a new row, in the same sheet. Is that possible?
thanks,



Origin Ver.8.0.63.988 and Service Release 6

WinXP

Penn

China
644 Posts

Posted - 09/15/2009 :  02:36:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

At present, Origin can't import .mat files as you want above. However, after importing all files, you can execute some scripts to re-organize your variables as a new row.

Now, I suppose your 6 variables all are singe value variables, but not matrices. After importing to Origin, 6 variables in each file are stored in first row of its own workbook. The workbook names are Book1, Book2, Book3, . Then run the following scripts in Command Window.

// define six ranges for column 1 to column 6, to store six variables in each file.
range a1 = [book1]sheet1!col(1);
range a2 = [book1]sheet1!col(2);
range a3 = [book1]sheet1!col(3);
range a4 = [book1]sheet1!col(4);
range a5 = [book1]sheet1!col(5);
range a6 = [book1]sheet1!col(6);

// loop from Book2 to Book n, variables in these books all are put to Book1.
for(ii=2;ii<n+1;ii++)
{
	range bo = [book$(ii)]; // define a range for Book ii.

	// define six ranges for column 1 to column 6 of Book ii.
	range b1 = [book$(ii)]sheet1!col(1);
	range b2 = [book$(ii)]sheet1!col(2);
	range b3 = [book$(ii)]sheet1!col(3);
	range b4 = [book$(ii)]sheet1!col(4);
	range b5 = [book$(ii)]sheet1!col(5);
	range b6 = [book$(ii)]sheet1!col(6);

	// put variables in Book ii to Book 1.
	a1[ii] = b1[1];
	a2[ii] = b2[1];
	a3[ii] = b3[1];
	a4[ii] = b4[1];
	a5[ii] = b5[1];
	a6[ii] = b6[1];
	delete bo; // delete Book ii.
}

Penn Lai
OriginLab Technical Services
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