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
 Reading matlab structure

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
couturier Posted - 05/16/2021 : 07:57:38 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2021b
Operating System: win10 64bit

Hi,
Are there any functions for importing a matlab structure into an OC struct or tree ?

thanks
6   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 06/03/2021 : 5:31:23 PM
The following code read a matrix stack to a matrix sheet and copy one of the matrix into a worksheet

void mdc(string strpath)
{
	MatrixPage mp;
	mp.Create("Origin", CREATE_HIDDEN);
	//add matlab connector to the matrix book
	mp.DoMethod("dc.Add", "MATLAB");
	MatrixLayer ml = mp.Layers();
	//setup the connection
	ml.SetProp("dc.Source", strpath);
	//set the selection path into the structure
	ml.SetProp("dc.Sel", "MATLAB/Fs2Fs_EMGinterpol_optiHz_norm");
	//this is to execute the actual import
	ml.DoMethod("dc.import");
	//you can remove the connector after import
	mp.DoMethod("dc.remove");

	//pick one of the matrix and transfer to a worksheet
	MatrixObject mobj = ml.MatrixObjects(4);

	WorksheetPage wp;
	wp.Create("Origin");
	Worksheet wks = wp.Layers();
	matrixbase& mb = mobj.GetDataObject();
	mb.CopyTo(wks, 0, 0, -1, -1, 0, 0, false, false);
}


I recommend that you play with the connector from GUI too
1. New Matrix
2. Data > Connect to File > Matlab

CP
cpyang Posted - 06/03/2021 : 1:00:54 PM
That tree is only the structure, it does not have actual values.

In order to read the data, we will need to give you sample code on using the MATLAB connector from OC.

CP
couturier Posted - 06/03/2021 : 05:01:44 AM
Thanks CP for that function
How can I put the data in a wks ?

void dt(string strFile)
{
	Tree tr;
	int nRet = OMAT_Make_import_tree(&tr, strFile, true, NULL);
	
	matrix mm;
	mm = tr.Fs2Fs_EMGinterpol_optiHz_norm._11._11.dVals2; // ---> returns bad storage method variable type
	
	Worksheet wks;
	wks.Create("Origin");  // Create a new worksheet
	mm.CopyTo(wks, 0, 0, -1, -1, 0, 0, FALSE, TRUE);  // Convert the data to worksheet
}


it returns bad storage method variable type
cpyang Posted - 05/17/2021 : 12:21:14 PM
This will give you the tree,


#include <../Originlab/oMATio.h>
void dt(string strFile)
{
	Tree tr;
	int nRet = OMAT_Make_import_tree(&tr, strFile, true, NULL);
	out_int("ret=", nRet);
}



CP
couturier Posted - 05/17/2021 : 02:16:11 AM
Yes, but I need to arrange the different parts of the data, so I'd like to access that tree in OC before putting the data into the wks
cpyang Posted - 05/16/2021 : 6:15:21 PM
Did you try the MATLAB Connector? It shows you a tree loading from the file. Is that what you need?

CP

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