Thread Subject: matlab class property viewable from .NET

Subject: matlab class property viewable from .NET

From: Chang shen

Date: 22 Jan, 2009 22:14:01

Message: 1 of 2

Hi All,
I have a class cfoo, How to access its properties from .NET? I defined those properties as public but in .NET, I can not see those properties. Any wrong?

classdef cfoo
    properties (SetAccess = public, GetAccess = public)
        avalue=0;
        aarray=[0,1];
    end
    method (Access = public)
        function out = myf(obj,in)
            out = in*avalue;
        end
    end
    
    %constructor
    method obj=cfoo(inv, ina)
        obj.avalue=inv;
        obj.aarray = ina;
    end
end


it compiled as .NET component MatlabDotNetDLL. I expected that I can access class properties avalue and aarray in .NET, like something objecy.property
But I can not see them. What is wrong?



C# code:

using MatlabDotNetDLL;

namespace example
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] aarray = new int[2];
            int avalue=3;

           MatlabDotNetDLL myclass = new MatlabDotNetDLL();
           MatlabDotNetDLL aclass = myclass.cfoo((MWArray)avalue, (MWArray)aarray);
  
         aclass.avalue=5; //????
         }
    }
}

Subject: matlab class property viewable from .NET

From: Titus

Date: 23 Jan, 2009 10:55:56

Message: 2 of 2


"Chang shen" <shencs@yahoo.com> schrieb im Newsbeitrag
news:glar39$ri3$1@fred.mathworks.com...
> Hi All,
> I have a class cfoo, How to access its properties from .NET? I defined
> those properties as public but in .NET, I can not see those properties.
> Any wrong?
>
> classdef cfoo
> properties (SetAccess = public, GetAccess = public)
> avalue=0;
> aarray=[0,1];
> end
> method (Access = public)
> function out = myf(obj,in)
> out = in*avalue;
> end
> end
>
> %constructor
> method obj=cfoo(inv, ina)
> obj.avalue=inv;
> obj.aarray = ina;
> end
> end
>
>
> it compiled as .NET component MatlabDotNetDLL. I expected that I can
> access class properties avalue and aarray in .NET, like something
> objecy.property
> But I can not see them. What is wrong?
>
>
>
> C# code:
>
> using MatlabDotNetDLL;
>
> namespace example
> {
> class Program
> {
> static void Main(string[] args)
> {
> int[] aarray = new int[2];
> int avalue=3;
>
> MatlabDotNetDLL myclass = new MatlabDotNetDLL();
> MatlabDotNetDLL aclass = myclass.cfoo((MWArray)avalue,
> (MWArray)aarray);
>
> aclass.avalue=5; //????
> }
> }
> }

Hi,

from the doc (Product Overview of MATLAB Builder NE):

Unsupported MATLAB Data Types
The MATLAB Builder NE product does not support MATLAB object data types (for
example, Time Series Objects) and most unsigned numeric types.

Allthough your MATLAB code may use object data types as you like, passing
the boundary of MATLAB/.NET does not work, i.e., you can call functions in
MATLAB but not directly access objects properties ...

Titus

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
net c propertie... C Shen 22 Jan, 2009 17:15:05
rssFeed for this Thread

Contact us at files@mathworks.com