Questions tagged [matlab-class]

One of the object oriented programming (OOP) features in MATLAB is the ability to define classes, which can be used to facilitate encapsulation of data and operations. Classes are defined in MATLAB within a `classdef` block, followed by `properties`, `methods`, `events` and `enumeration` subblocks.

103 questions
3
votes
2 answers

inheriting from MATLAB graphics objects

I need to create subclass of the Patch object's class in MATLAB 2014b but MATLAB does not allow me to do so: Class 'matlab.graphics.primitive.Patch' is Sealed and may not be used as a superclass. Is there a hack around this?
Sia
  • 919
  • 1
  • 8
  • 18
3
votes
1 answer

Extending matlab classes: new methods for built-in classes

I inherited a complete toolbox, last revised in 2006, and I must update it to the latest version of Matlab. This toolbox defines some classes and defines methods for built in classes. More specifically, it creates some extra methods for objects of…
user3869571
3
votes
3 answers

Why does MATLAB throw an "undefined variable" error when I try to assign a class property to another class property in the properties block?

If I run this code to create a simple class: classdef myclass properties m = 2; n = m + 2; end end I get an error: Undefined function or variable 'm'. Error in myclass (line 1) classdef myclass Why is this? I left out the…
Michael A
  • 4,391
  • 8
  • 34
  • 61
3
votes
2 answers

Too many input parameters error from class method

I have writen a class in MATLAB like below: classdef sizeInfo properties end methods function [row column] = getSize(m) [row column] = size(m); end end end When I make use of this class's getSize function, it always reports a…
MengT
  • 1,207
  • 2
  • 14
  • 16
3
votes
1 answer

Referencing Static Functions in Matlab

For an object in MATLAB, is it possible to call a static function of the same type without knowing the encompassing package? Right now, the only way I've found to reference it is to use Package.Whatever.staticfunction(), but I'd like to properly…
kevmo314
  • 4,223
  • 4
  • 32
  • 43
3
votes
2 answers

Why does MATLAB delete breakpoints in my classdef?

I am trying to debug an object-oriented application in MATLAB R2011b that I did not write myself. To do this, I want to place a breakpoint in a method in the classdef. As far as I know, this is allowed. Yet, when I run the application, the…
Stephen Bosch
  • 273
  • 1
  • 11
2
votes
1 answer

define enum type

I would like to create a function that contains all text and constant. From the other .m files I access to the constants with giving the name of function variable. For example, in Java: public enum MyEnum { …
lola
  • 5,649
  • 11
  • 49
  • 61
2
votes
3 answers

Callback Functions using Timers in Matlab

I am working on a statistical model of a content distribution server in MATLAB and have decided to use OO programming. This is my first foray into OO with MATLAB and I have hit a snag. I am attempting to model a download connection to the server, at…
Rabid
  • 326
  • 4
  • 14
2
votes
1 answer

Understanding MATLAB class properties

Considering this example from the MATLAB Help. This example, besides having syntax problems, does not seams to work for me. I don't know if is a version issue, I'm using R2013a. classdef MyClass properties (Constant = true) X = pi/180; …
Pablo Riera
  • 349
  • 3
  • 15
2
votes
3 answers

Static property in Matlab

I want an OOP like interface with Matlab, in a way that I have something like classdef Foo properties (Constant) dict = NaN; end methods (Static) function list = search(varargin) %... Foo.dict = cell(10,5); % etc.. end end end So I…
casparjespersen
  • 3,460
  • 5
  • 38
  • 63
2
votes
1 answer

Matlab unable to call superclass method

I'm new to Matlab and am facing some problems with calling superclass methods. I've got this code: Superclass test1: classdef test1 < handle methods function obj = test1() end function test2(obj) disp(1); …
2
votes
3 answers

importing java classes in matlab classdef

I have a matlab class defined using classdef. I'm creating a wrapper for some java stuff and need to import several classes. I can't figure out where to import these classes, so far I can import them as needed in each method... which is…
danatron
  • 667
  • 1
  • 9
  • 19
2
votes
1 answer

How to change the property of an instance in Matlab

I'm new to MATLAB, and I want to write a method of a class that change the property of this object: classdef Foo properties a = 6; end methods function obj = Foo() end function change(obj,bar) obj.a = bar end …
mko
  • 21,334
  • 49
  • 130
  • 191
2
votes
1 answer

Why do I get a “Too many input arguments” error when passing in proper parameters?

Why am I getting an error: ??? Error using ==> ensureCellType Too many input arguments. Error in ==> usage_dynamicVariableNaming at 11 result = dataHolder.ensureCellType(str); when I am passing in right number of parameters? % USAGE: clear…
Ursa Major
  • 851
  • 7
  • 25
  • 47
2
votes
1 answer

How to save MATLAB classes to file

I would like to load and save some objects instantiated from a classdef style class. I can use "save" and "load" when the objects exist in the workspace, but not outside. For example, if I have a class called manager, that needs to load and save…
danatron
  • 667
  • 1
  • 9
  • 19