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
 Origin Forum
 problem importing mat files

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
rockyraccoon Posted - 09/10/2009 : 09:07:18 AM
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
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 09/15/2009 : 02:36:55 AM
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

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