All,
I am trying to set platform preferences dynamically based on User Input collected using a UI.
Essentially, the user specifies which Matlab version is installed on their machine and I am using that to construct a 32-bit and a 64-bit path to the root variable for Matlab on the users machine. However, this repeatedly results in an error:
Unexpected "\MATLAB\R2018a\". Perhaps there is a missing "," or ")".
Trying to parse arguments of function "MATLABROOT32".
Any help or advice is appreciated.
</CODE><CODE class=" language-jsl"></CODE></PRE><P> </P></LINGO-BODY><LINGO-SUB id="lingo-sub-218435" slang="en-US">Re: Set Platform Preferences using a variable</LINGO-SUB><LINGO-BODY id="lingo-body-218435" slang="en-US"><P>Thanks to <A href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4881" target="_blank">@gblatz</A> , the following works: </P><P> </P><PRE><CODE class=" language-jsl">Eval(
Parse(
Eval Insert(
" Platform Preferences( PathVar( MATLABROOT32( \!"^matlab_32bit_path^ \!" ), MATLABROOT( \!"^matlab_64bit_path^\!" ) ) );"
)
)
);user_matlab_ver = '2018a' ; // for example <BR />matlab_32bit_path = "C:\Program Files (x86)\MATLAB\R2018a\";
matlab_64bit_path = "C:\Program Files\MATLAB\R2018a\";
Eval( Parse( Eval Insert("\[ Platform Preferences( PathVar( MATLABROOT32( ^matlab_32bit_path^ ), MATLABROOT( ^matlab_64bit_path^ ) ) );]\" ) ) );
ConnectToMatlab = Expr(
matlab_conn = MATLAB Connect();
matlab_conn_flag = matlab_conn << Is Connected;
);
ConnectToMatlab;
The issue you had with the quoted strings is one of the reasons I usually prefer Eval(Substitute()) or Eval(EvalExpr())
Eval(
Substitute(
Expr(
Platform Preferences(
PathVar(
MATLABROOT32( "DV_ML32" ),
MATLABROOT( "DV_ML64" )
)
)
),
"DV_ML32", matlab_32bit_path,
"DV_ML64", matlab_64bit_path
)
);