photo

Rani Feldman


WDC

自 2018 起处于活动状态

Followers: 0   Following: 0

消息

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

统计学

MATLAB Answers

1 个提问
0 个回答

排名
258,604
of 301,432

声誉
0

贡献数
1 个提问
0 个回答

回答接受率
0.0%

收到投票数
0

排名
 of 21,280

声誉
N/A

平均
0.00

贡献数
0 文件

下载次数
0

ALL TIME 下载次数
0

排名

of 174,555

贡献数
0 个问题
0 个答案

评分
0

徽章数量
0

贡献数
0 帖子

贡献数
0 公开的 个频道

平均

贡献数
0 个亮点

平均赞数

Feeds

排序方式:

提问


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 前 | 0 个回答 | 0

0

个回答