photo

Rani Feldman


WDC

Active since 2018

Followers: 0   Following: 0

Message

I am using level 2 Matlab S-function. Also I have a class that I define that calculates something.
I want to have 2 instances of the same level 2 Matlab S-Function using the same class.
But each instance of the S-Function should have it's different instance of the class.
So in:
function InitializeConditions(block)
test = myClass(5);
%end InitializeConditions
and then in:
function Outputs(block)
test.increment();
block.OutputPort(1).Data = test.a;
%end Outputs

I need each class to have it's own instance.
- Using global is not good because I will have only 1 instance of the class.
- I cannot use DWork to store the class.

classdef myClass < handle
properties
a;
end
methods
function obj = myClass(a)
obj.a = a;
end
function increment(obj)
obj.a = obj.a + 100;
end
end
end

Statistics

MATLAB Answers

1 Question
0 Answers

RANK
258,604
of 301,436

REPUTATION
0

CONTRIBUTIONS
1 Question
0 Answers

ANSWER ACCEPTANCE
0.0%

VOTES RECEIVED
0

RANK
 of 21,278

REPUTATION
N/A

AVERAGE RATING
0.00

CONTRIBUTIONS
0 Files

DOWNLOADS
0

ALL TIME DOWNLOADS
0

RANK

of 174,540

CONTRIBUTIONS
0 Problems
0 Solutions

SCORE
0

NUMBER OF BADGES
0

CONTRIBUTIONS
0 Posts

CONTRIBUTIONS
0 Public Channels

AVERAGE RATING

CONTRIBUTIONS
0 Discussions

AVERAGE NO. OF LIKES

Feeds

View by

Question


Using classes in level 2 Matlab S-function
I am using level 2 Matlab S-function. Also I have a class that I define that calculates something. I want to have 2 instances o...

8 years ago | 0 answers | 0

0

answers