Object Oriented Programming - How to Use Cass Instances in Simulink

조회 수: 1 (최근 30일)
Yu Zhao
Yu Zhao 2016년 5월 18일
I want to program a highway simulation. The vehicle class contains several member variables, a constructor and an update method.
classdef veh_states
properties
ID;
x;
y;
lane;
speed; %[m/s]
acceleration; %[m/s^2]
heading; %[rad]
end
methods
function veh_new = veh_states(n)
%generate n random vehicles and store in array veh_new
end
function update(veh_array)
%update vehicle positions
end
end
end
Then I created a global instance of the vehicle array in a script.
global veh_array;
veh_array = veh_states(6);
Now is it possible to call update method in a embedded Matlab function within a Simulink model and how do I realise it?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by