How to call matlab class method from simulink

조회 수: 9(최근 30일)
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);
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;
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);

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by