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
 Importing Matlab variables

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
nicholas.cade@crick.ac.uk Posted - 12/17/2018 : 09:38:01 AM
Operating System: OriginPro 2018b

I want to import a Matlab .mat file into a new workbook and then automatically run a script on the data.
I can see the structure of the file and the variables it contains using the Matlab import function, if I tick the "Import into Hierarchical Structure" option.
How do I then programmatically load the individual variables into e.g. new worksheets? I can click on the variable names to load them, but need to automate this.
If I do not tick the Hierarchical import option, I get a blank workbook and no option to choose the individual variables - there is a message "The file may be created by a newer version of MATLAB."
I've tried saving the .mat file with all the possible versions, which makes no difference.
Thanks
3   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 12/18/2018 : 09:19:00 AM
Hi,

Please change last line of the script to:
OCHDF5_UserCallback(strVar1$, strVar2$);


Thanks,
James
nicholas.cade@crick.ac.uk Posted - 12/18/2018 : 05:34:56 AM
Thanks, but I just get a blank new worksheet appearing.
I'll send an example .mat file

quote:
Originally posted by YimingChen

Hi,

Assume you import your data in hierarchical structure, activate the worksheet, then run the following LabTalk script in Windows->Script Window:

//specify the row idx of the variable to show
idx = 2;
page.active = 1;
strFunc$ = Token(cell(idx,1)$,3,":")$;
strVar1$ =  Token(strFunc$,2,"|")$;
strVar2$ =  Token(strFunc$,3,"|")$;
matfile_UserCallback(strVar1$, strVar2$);


Also could you send us an example of your .mat file? It should be able to import without ticking the Hierarchical import option. Please send it to <tech@originlab.com> if you want us to check further. Thank you.

James

YimingChen Posted - 12/17/2018 : 12:13:48 PM
Hi,

Assume you import your data in hierarchical structure, activate the worksheet, then run the following LabTalk script in Windows->Script Window:

//specify the row idx of the variable to show
idx = 2;
page.active = 1;
strFunc$ = Token(cell(idx,1)$,3,":")$;
strVar1$ =  Token(strFunc$,2,"|")$;
strVar2$ =  Token(strFunc$,3,"|")$;
matfile_UserCallback(strVar1$, strVar2$);


Also could you send us an example of your .mat file? It should be able to import without ticking the Hierarchical import option. Please send it to <tech@originlab.com> if you want us to check further. Thank you.

James

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