| Author |
Comment/Response |
Fahd
|
06/21/12 4:23pm
I have the following code
{
if(MLConnect(mlp))
{ mexPrintf("\n Connected Properly \n",0);}
MLPutSymbol(mlp,"$Version");
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
if(MLGetType(mlp)==MLTKSTR)
{
MLGetString(mlp,&response);
printf("%s \n",response);
}
else
{
printf("Error \n");
}
MLPutString(mlp,"aaaa");
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
if(MLGetType(mlp)==MLTKSTR)
{
MLGetString(mlp,&response);
printf("%s \n",response);
}
else
{
printf("Error \n");
}
MLEndPacket(mlp);
MLPutInteger(mlp,2);
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
MLGetInteger(mlp,&sum);
printf("%i \n",sum);
MLEndPacket(mlp);
i=4;
j=2;
MLPutFunction(mlp, "Plus", 2);
MLPutInteger(mlp,i);
MLPutInteger(mlp,j);
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
MLGetInteger(mlp,&sum);
printf("integer sum is %i \n",sum);
sum=1;
MLPutFunction(mlp, "EvaluatePacket", 1);
MLPutFunction(mlp, "ToExpression", 1);
MLPutString(mlp, "3.1+2.2");
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
MLGetFloat(mlp,&x);
printf("integer sum is %f \n",x);
MLEndPacket(mlp);
}
The Output is the following:
"
Connected Properly
8.0 for Microsoft Windows(64-bit)(November 7,2010)
aaaa
2
integer sum is 6
integer sum is 0.000000
"
The only part not working is the last one i.e.
MLPutFunction(mlp, "EvaluatePacket", 1);
MLPutFunction(mlp, "ToExpression", 1);
MLPutString(mlp, "3.1+2.2");
MLEndPacket(mlp);
WaitForReturnPacket(mlp);
MLGetFloat(mlp,&x);
printf("integer sum is %f \n",x);
Can anyone point out the mistake in this code. I am unable to retrieve floating/double data type from mathematica.
Best Regards.
URL: , |
|