Subscribe Bookmark RSS Feed

Problem using MATLAB Get to retrieve matrices and scalars (unable to retrieve data)


Community Member


Jan 23, 2017

Using a series of complex nested functions initiated by one script (imagemeasure5.m), I have created two structure arrays in MATLAB. These structure arrays each contain two scalars and two 1 column, ~ 500 row matrices. the structure arrays are named outputa and outputb. My goal is to individually save the elements in these arrays to variables in JMP


Everything I've found online and in other questions indicates that once MATLAB is initialized and a script is run, MATLAB Get can be used to retrieve data types including matrices & scalars and save them into JMP variables. Here are the three ways I've tried to do it, with all my matlab initialization codes included: 

Platform Preferences(
	pathvar(MATLABROOT( "C:\Program Files\MATLAB\R2016b" )));
Names Default To Here( 1 ); 
gui_directory = "'C:\Users\mredford\Desktop\MATLAB Import 3.1'"; 
mlconn = MATLAB Connect(); // Connects to Matlab
MATLAB Init(); // Initializes Matlab
MATLAB Submit( "clc,clear all,close all,imtool close all" );

MATLAB Submit( "cd " || gui_directory ); 
Try( MATLAB Send( ::jmp_previous_path ), show("Previous Image Path Not Found") );

MATLAB Submit( "imagemeasure5" );

scalefactorone = MATLAB Get( outputa.Xs); //trying to reference using structure array 
scalefactortwo = MATLAB Get(pixmermm); // attempting to reference using a simple saved scalar variable 
scalefactorthree = MATLAB Get("pixpermm"); //trying quotes since some sources said to 

For some reason, however, whether I am referencing a simple named scalar in MATLAB, or the structure array, or any other type of normal MATLAB variable, the output of Matlab Get() is ALWAYS 1. I know I can save the MATLAB data to a file and import it instead, but since this program will likely be run hundreds of times that seems excessive. 

I don't think there is a problem with my connection, as the script is running and storing the variables in the workspace of MATLAB just fine. I can't figure out why this syntax seemingly works for everyone else or where I am going wrong. 

I don't really mind how at this point, I just need a good way to script automatic storage of these variables in JMP for further analysis.