How to call matlab class method from simulink

10 ビュー (過去 30 日間)
OT
OT 2022 年 7 月 29 日
回答済み: Mark McBroom 2022 年 8 月 3 日
I want to use functions/methods from matlab class in Simulink simulation. matlab Function Block contains:
function y = fcn(u)
y = dsp.calc_val(u);
end
dsp is an instance of class t_dsp, method calc_val is defined and can be called from matlab workspace,
classdef t_dsp < handle
methods(Access = public)
function out = calc_val(obj, x)
out = obj.some_value + x * 2;
end
end
but Simulink produces this error message:
Undefined function or variable 'dsp.calc_val'
Class instance is not visible from the matlab Function Block. I don't want to go for 'MATLAB System' class, I want to re-use already existing matlab class. How it can be done?

採用された回答

Mark McBroom
Mark McBroom 2022 年 8 月 3 日
function y = fcn(u)
dsp = t_dsp;
y = dsp.calc_val(u);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with DSP System Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by