From: XYZ on
Hi,

I want to create my own class modem.myModFormat to inherit modem
modulator properties. I tried to follow Matlab's help on subclassing but
can't get this to work. My code looks like:

classdef myModFormat < modem
methods
function obj = myModFormat(data)
obj = obj(a)modem(data); % initialize the base class portion
end
end
end

This, of course, doesn't work.

First of all, is there any way to inherit modem modulator properties or
do I need to subclass either modem.genqammod or any other modulator in
modem class?
I want to keep this class together with my other m-files and not in
Matlab's toolbox dir. What directory structure should I use then? Tried
<path>\@modem\@myModFormat\myModFormat.m but Matlab doesn't see this
although <path> dir was in Matlab's path as a last one.

Thank on any clues on how to accomplish that. Know that this may seem
trivial but it's the first time I'm working with classes in Matlab.

Best,
Bob
From: Matt J on
XYZ <junk(a)mail.bin> wrote in message <hm1o5u$drf$1(a)news.onet.pl>...
> Hi,
>
> I want to create my own class modem.myModFormat to inherit modem
> modulator properties. I tried to follow Matlab's help on subclassing but
> can't get this to work. My code looks like:
>
> classdef myModFormat < modem
> methods
> function obj = myModFormat(data)
> obj = obj(a)modem(data); % initialize the base class portion
> end
> end
> end
>
> This, of course, doesn't work.
=================

I doubt it will be clear to people why this doesn't work unless you tell us what happened when you tried it. Not unless, of course, they have the Communication Toolbox and can try it themselves.

> First of all, is there any way to inherit modem modulator properties or
> do I need to subclass either modem.genqammod or any other modulator in
> modem class?
=================

If I had to guess, though, I would conjecture that the modem class might be Sealed so that you cannot inherit from it. To find out, type ?modem

> I want to keep this class together with my other m-files and not in
> Matlab's toolbox dir. What directory structure should I use then? Tried
> <path>\@modem\@myModFormat\myModFormat.m but Matlab doesn't see this
> although <path> dir was in Matlab's path as a last one.

If the modem class is unsealed, you should be able to put your subclass classdef anywhere in your MATLAB path.

From: XYZ on
On 2010-02-24 03:13, Matt J wrote:
> XYZ <junk(a)mail.bin> wrote in message <hm1o5u$drf$1(a)news.onet.pl>...
>> Hi,
>>
>> I want to create my own class modem.myModFormat to inherit modem
>> modulator properties. I tried to follow Matlab's help on subclassing
>> but can't get this to work. My code looks like:
>>
>> classdef myModFormat < modem
>> methods
>> function obj = myModFormat(data)
>> obj = obj(a)modem(data); % initialize the base class portion
>> end
>> end
>> end
>>
>> This, of course, doesn't work.
> =================
>
> I doubt it will be clear to people why this doesn't work unless you tell
> us what happened when you tried it. Not unless, of course, they have the
> Communication Toolbox and can try it themselves.
I get an error
??? Undefined variable "modem" or class "modem.myModFormat".

>
>> First of all, is there any way to inherit modem modulator properties
>> or do I need to subclass either modem.genqammod or any other modulator
>> in modem class?
> =================
>
> If I had to guess, though, I would conjecture that the modem class might
> be Sealed so that you cannot inherit from it. To find out, type ?modem
What I get is: ??? No meta-class available for class 'modem'. The same
is for each of its subclasses.
I've been browsing through modem code but can't find properties such as
M or Constellation defined there. Apparently modem class is just a
'placeholder' (it doesn't even seem to be a superclass) for classes like
modem.genqammod, which in turn use modem.baseclass to initialize. I did
not find any classdef statement so I guess modem in R2008a was not
rewritten with new class syntax. Is it still possible to inherit in that
case?

>> I want to keep this class together with my other m-files and not in
>> Matlab's toolbox dir. What directory structure should I use then?
>> Tried <path>\@modem\@myModFormat\myModFormat.m but Matlab doesn't see
>> this although <path> dir was in Matlab's path as a last one.
>
> If the modem class is unsealed, you should be able to put your subclass
> classdef anywhere in your MATLAB path.
How you define whether Matlab class is sealed or not? I could not find
any meaningful help on this.

Rob
From: Matt J on
XYZ <junk(a)mail.bin> wrote in message <hm40ep$9hb$1(a)news.onet.pl>...
> On 2010-02-24 03:13, Matt J wrote:

> Apparently modem class is just a
> 'placeholder' (it doesn't even seem to be a superclass)
============

We need to find out what the name of the class really is. Try creating a modem object obj and finding its class by typing

>>class(obj),



> How you define whether Matlab class is sealed or not? I could not find
> any meaningful help on this.

It's a class attribute. If the 1st line in your classdef file looks like the following

classdef (Sealed) myClass

then myClass cannot be subclassed. See the MATLAB OOP documentation for full details.
From: XYZ on
On 2010-02-24 21:22, Matt J wrote:
> XYZ <junk(a)mail.bin> wrote in message <hm40ep$9hb$1(a)news.onet.pl>...
>> On 2010-02-24 03:13, Matt J wrote:
>
>> Apparently modem class is just a 'placeholder' (it doesn't even seem
>> to be a superclass)
> ============
>
> We need to find out what the name of the class really is. Try creating a
> modem object obj and finding its class by typing
>
>>> class(obj),
>
It's not possible to create modem object. I can only create modem.qammod
or similar. Modem seems to be provide help only. See this:

>> modem
??? Error using ==> modem.modem at 25
Use MODEM.<TYPE> to create a modulation object.
For example,
h = modem.pskmod

>> h=modem.genqammod

h =

Type: 'General QAM Modulator'
M: 16
Constellation: [1x16 double]
InputType: 'Integer'

>> class(h)

ans =

modem.genqammod

>> modem.baseclass
??? Error using ==> modem.baseclass.baseclass at 9
This is an abstract class.

>
>
>> How you define whether Matlab class is sealed or not? I could not find
>> any meaningful help on this.
>
> It's a class attribute. If the 1st line in your classdef file looks like
> the following
>
> classdef (Sealed) myClass
>
> then myClass cannot be subclassed. See the MATLAB OOP documentation for
> full details.
No classdef inside any m-file in @modem directory and all subdirectories.

Best,
Rob
 |  Next  |  Last
Pages: 1 2
Prev: World Ocean Database
Next: singular matrix