Interaction between MATLAB 32bit and MATLAB 64bit

2 views (last 30 days)
PROBLEM
I have two tools written in MATLAB (I am not the author):
1. the first allows me to retrieve some data from a SQL database, but it works only on MATLAB 64bit (I have MATLAB 2016b 64bit).
2. the second uses the data retrieved from the first tool and, through a DLL compiled on a 32bit system, it gets some outputs. As said, this tool works only MATLAB 32bit (I have MATLAB 2013a 32bit).
What I would like to do is:
1. get the data from SQL, in MATLAB 64bit
2. "send them" in some way to MATLAB 32bit
3. run the tool on MATLAB 32bit
4. "return" the outputs from MATLAB 32bit to MATLAB 64bit
I know a solution may be found using IPC mechanisms, but I am not sure how to find them or how to use them in MATLAB. Does anyone ever worked with this kind of stuff?
Looking into the MATLAB documentation I saw that it is possible to create a **COM object**, but I am not sure how to use it to run some functions in MATLAB 32bit.
SOLUTION
Unfortunately the solutions below did not help to solve the problem. Though, I managed to get the results I wanted using system commands. The correct answer can be found at the link below.

Answers (1)

Guillaume
Guillaume on 12 Jul 2019
I'm not clear why step 1 requires a particular bitness. The majority of databases will provide a 32-bit and 64-bit ODBC driver. In fact, looking at my computer, I've got more 32-bit drivers than 64-bit ones.
You could indeed use COM to communicate between the 32 bit and 64 bit matlab, as long as they're different versions. Probably... it's not something I've ever tested. You'd use the version dependent ProgID to locate the 32-bit version of matlab.
So, from the 64-bit matlab, it would look like:
matlab32 = actxserver('Matlab.Application.8.1'); %8.1 is R2013a according to wikipedia
matlab32.Execute('some script');
result = matlab32.Feval('Some function', input1, input2);
matlab32.Quit
But maybe it's time to rewrite these tools. R2013 is getting long in the tooth.
  3 Comments
Guillaume
Guillaume on 12 Jul 2019
Edited: Guillaume on 12 Jul 2019
With that function signature, it would be:
%from matlab 64 bit
output = matlab32.Feval('runScript', 1, input); %1 to say that the function has 1 output
output = output{1}; %Feval always return a cell array containing all the ouputs
As another example, if you wanted to use Feval to call the matlab function ndgrid to build two arrays:
out = matlab32.Feval('ndgrid', 2, 1:4, 1:5); %2 outputs
x = out{1}; y = out{2}; %could also be written [x, y] = deal(out{:});
%this is equivalent to:
%[x, y] = ndgrid(1:4, 1:5)
Federico
Federico on 12 Jul 2019
If I try to run the second function you mentioned it works perfectly. If I run my function I get this error
Error using COM.Matlab_Application_8_1/Feval
Invoke Error, Dispatch Exception:
Source: Matlab.MLApp
Description:
I tried even to modify it to a basic one like
function output = runScript(input)
output = input * 2;
end
but it throws the same error. The runScript function is in the same folder I am working in, so I am not sure what I am missing.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!