[python-win32] How to handle arguments of "Pointer SafeArray Real 8 (Flags=3)"

Jingzhao Ou ouj@usc.edu
Sun, 23 Mar 2003 23:58:30 -0800 (PST)


Dear all,

I just checked using google. It seems that Perl guys have some good solutions
to this problem. I really would like to solve this problem using Python. 

Thanks!

Best regards,
Jingzhao

============================================================
# First create two SAFE_ARRAYs (Can only pass SAFE_ARRAY?)
my $MReal = Variant(VT_ARRAY|VT_R8, [1,2], 2);
my $MImag = Variant(VT_ARRAY|VT_R8, [1,2], 2);

# Set the values
$MReal->Put(1,0,1.2345678901234567890123456789);
$MReal->Put(1,1,2);
$MReal->Put(2,0,3);
$MReal->Put(2,1,4);

# Put the matrix into MATLAB
$ML->PutFullMatrix('B', 'base', $MReal, $MImag);

# GetFullMatrix is similar but requires unpacking the data
# from MATLAB into the Variant array.  The data is passed
# from MATLAB by reference.

# Make real and complex arrays for the data.
my $M2Real = Variant(VT_ARRAY|VT_R8|VT_BYREF, [1,2], 2);
my $M2Imag = Variant(VT_ARRAY|VT_R8|VT_BYREF, [1,2], 2);

# Retrieve the data from MATLAB
$ML->GetFullMatrix('B', 'base', $M2Real, $M2Imag);

============================================================


--- Jingzhao Ou <jasonou@yahoo.com> wrote:
> Hi, 
> 
> I tried to use MATLAB from python through the MATLAB COM server. I use
> the following code to invoke the COM server:
> 
> App = win32com.client.dynamic.Dispatch('Matlab.Application')
> 
> Then, after that, I can execute MATLAB commands using 
> 
> App.Execute(command)
> 
> However, I encountered problem when I tried to import/export data from/to
> MATLAB using the GetFullMatrix and PutFullMatrix functions. I check the input
> to these two functions. They require arguments of "Pointer SafeArray Real 8
> (Flags=3)" type. I tried to use list or tuple data type in python to handle
> them  but failed. 
> 
> Can anyone help me out by telling how I can solve this problem in python?
> Should I write some C code to solve it? 
> 
> BTW, VB can handle this data type. 
> 
> Thanks!
> 
> Best regards,
> Jingzhao
> 
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32