-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexample_1.m
39 lines (29 loc) · 1 KB
/
example_1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%% Init
close all
import matsim.library.*
% Create or load model
sys = simulation.load('matsim_model');
sys.setSolver('Ts',0.01,'DiscreteOnly',true)
sys.clear()
sys.show()
%% Create
Vx = FromWorkspace('V_x'); % Add FromWorkspace and Constant blocks
Wr = FromWorkspace('W_r');
Rr = Constant(0.32);
slip = 1 - Vx./(Wr.*Rr); % Evaluate complex mathematical expression
slip.outport(1,'name','slip'); % Set signal name and line label
sys.log(slip) % Log the output of the "slip" block
s = Scope(slip); % Create and open scope block
s.open()
%% Layout & connect
sys.layout() % Connect and layout model
%% Simulate the system
V_x = [0:0.1:10;linspace(5,20,101)]'; % Define input variables
W_r = [0:0.1:10;linspace(5,23,101)/0.32]';
simOut = sys.run('StopTime',10).Logs; % Simulate the system
figure
hold on
grid on
plot(simOut.slip)
% sys.save()
% sys.close()