Thread Subject:
How to pass strings using .NET to Matlab

Subject: How to pass strings using .NET to Matlab

From: Woody Davis

Date: 30 Nov, 2006 16:13:10

Message: 1 of 6

I am trying to pass an array of strings from C# to the .NET component
I created in Matlab. I am getting a compile time error in Visual
Studio telling me that it can't convert a string array to a MWArray.
I have tried performing explicit conversions, but none of them work.
Any help would be greatly appreciated.

Here is an example of what I am trying to do:

[C#]
using MathWorks.MATLAB.NET.Arrays;
using MyMatlabNet;
...
MyMatlabNetClass myclass = new MyMatlabNetClass();
...
string [] mydata;

myclass.somemethod(mydata);

I have tried (MWArray), (MWCharArray), (MWCellArray) and nothing
works (allows it to compile).

Subject: How to pass strings using .NET to Matlab

From: Woody

Date: 1 Dec, 2006 10:08:22

Message: 2 of 6

Any suggestions???
 

Woody Davis wrote:
>
>
> I am trying to pass an array of strings from C# to the .NET
> component
> I created in Matlab. I am getting a compile time error in Visual
> Studio telling me that it can't convert a string array to a
> MWArray.
> I have tried performing explicit conversions, but none of them
> work.
> Any help would be greatly appreciated.
>
> Here is an example of what I am trying to do:
>
> [C#]
> using MathWorks.MATLAB.NET.Arrays;
> using MyMatlabNet;
> ...
> MyMatlabNetClass myclass = new MyMatlabNetClass();
> ...
> string [] mydata;
>
> myclass.somemethod(mydata);
>
> I have tried (MWArray), (MWCharArray), (MWCellArray) and nothing
> works (allows it to compile).

Subject: How to pass strings using .NET to Matlab

From: Woody

Date: 5 Dec, 2006 09:18:19

Message: 3 of 6

Any suggestions??

 Woody Davis wrote:
>
>
> I am trying to pass an array of strings from C# to the .NET
> component
> I created in Matlab. I am getting a compile time error in Visual
> Studio telling me that it can't convert a string array to a
> MWArray.
> I have tried performing explicit conversions, but none of them
> work.
> Any help would be greatly appreciated.
>
> Here is an example of what I am trying to do:
>
> [C#]
> using MathWorks.MATLAB.NET.Arrays;
> using MyMatlabNet;
> ...
> MyMatlabNetClass myclass = new MyMatlabNetClass();
> ...
> string [] mydata;
>
> myclass.somemethod(mydata);
>
> I have tried (MWArray), (MWCharArray), (MWCellArray) and nothing
> works (allows it to compile).

Subject: How to pass strings using .NET to Matlab

From: Renier

Date: 6 Dec, 2006 04:48:49

Message: 4 of 6

Hi,

have you solved this problem? I need to convert []string to
MWCellArray and face the same problem too.

Thank you.

-m-

 Woody wrote:
>
>
> Any suggestions??
>
> Woody Davis wrote:
>>
>>
>> I am trying to pass an array of strings from C# to the .NET
>> component
>> I created in Matlab. I am getting a compile time error in
Visual
>> Studio telling me that it can't convert a string array to a
>> MWArray.
>> I have tried performing explicit conversions, but none of them
>> work.
>> Any help would be greatly appreciated.
>>
>> Here is an example of what I am trying to do:
>>
>> [C#]
>> using MathWorks.MATLAB.NET.Arrays;
>> using MyMatlabNet;
>> ...
>> MyMatlabNetClass myclass = new MyMatlabNetClass();
>> ...
>> string [] mydata;
>>
>> myclass.somemethod(mydata);
>>
>> I have tried (MWArray), (MWCharArray), (MWCellArray) and
nothing
>> works (allows it to compile).

Subject: How to pass strings using .NET to Matlab

From: Woody

Date: 7 Dec, 2006 11:05:25

Message: 5 of 6

I did resolve the problem. You can do the following:

1. Create an MWCharArray, passing in the string array in the
constructor.
2. Then use the MWCharArray object to create an MWCellArray by
passing in the MWCharArray into the constructor.

This will allow the array to be passed properly to the Matlab .NET
component.

 Renier wrote:
>
>
> Hi,
>
> have you solved this problem? I need to convert []string to
> MWCellArray and face the same problem too.
>
> Thank you.
>
> -m-
>
> Woody wrote:
>>
>>
>> Any suggestions??
>>
>> Woody Davis wrote:
>>>
>>>
>>> I am trying to pass an array of strings from C# to the .NET
>>> component
>>> I created in Matlab. I am getting a compile time error in
> Visual
>>> Studio telling me that it can't convert a string array to a
>>> MWArray.
>>> I have tried performing explicit conversions, but none of
> them
>>> work.
>>> Any help would be greatly appreciated.
>>>
>>> Here is an example of what I am trying to do:
>>>
>>> [C#]
>>> using MathWorks.MATLAB.NET.Arrays;
>>> using MyMatlabNet;
>>> ...
>>> MyMatlabNetClass myclass = new MyMatlabNetClass();
>>> ...
>>> string [] mydata;
>>>
>>> myclass.somemethod(mydata);
>>>
>>> I have tried (MWArray), (MWCharArray), (MWCellArray) and
> nothing
>>> works (allows it to compile).

Subject: How to pass strings using .NET to Matlab

From: Renier

Date: 8 Dec, 2006 04:49:32

Message: 6 of 6

That works. Thank you Woody. :)

 Woody wrote:
>
>
> I did resolve the problem. You can do the following:
>
> 1. Create an MWCharArray, passing in the string array in the
> constructor.
> 2. Then use the MWCharArray object to create an MWCellArray by
> passing in the MWCharArray into the constructor.
>
> This will allow the array to be passed properly to the Matlab .NET
> component.
>
> Renier wrote:
>>
>>
>> Hi,
>>
>> have you solved this problem? I need to convert []string to
>> MWCellArray and face the same problem too.
>>
>> Thank you.
>>
>> -m-
>>
>> Woody wrote:
>>>
>>>
>>> Any suggestions??
>>>
>>> Woody Davis wrote:
>>>>
>>>>
>>>> I am trying to pass an array of strings from C# to the
> .NET
>>>> component
>>>> I created in Matlab. I am getting a compile time error
> in
>> Visual
>>>> Studio telling me that it can't convert a string array
to
> a
>>>> MWArray.
>>>> I have tried performing explicit conversions, but none
of
>> them
>>>> work.
>>>> Any help would be greatly appreciated.
>>>>
>>>> Here is an example of what I am trying to do:
>>>>
>>>> [C#]
>>>> using MathWorks.MATLAB.NET.Arrays;
>>>> using MyMatlabNet;
>>>> ...
>>>> MyMatlabNetClass myclass = new MyMatlabNetClass();
>>>> ...
>>>> string [] mydata;
>>>>
>>>> myclass.somemethod(mydata);
>>>>
>>>> I have tried (MWArray), (MWCharArray), (MWCellArray)
and
>> nothing
>>>> works (allows it to compile).

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us