From c4e48007f1d4991b7968c9571c14ac7476afc5f4 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Mon, 10 Sep 2018 16:37:53 +0000 Subject: [PATCH] reorganized git-svn-id: http://moon:8086/svn/projects/HendiControl@4 fda53097-d464-4ada-af97-ba876c37ca34 --- matlab/mass.m | 15 +++++++++++++++ matlab/mass_eval.m | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 matlab/mass.m create mode 100644 matlab/mass_eval.m diff --git a/matlab/mass.m b/matlab/mass.m new file mode 100644 index 0000000..d977584 --- /dev/null +++ b/matlab/mass.m @@ -0,0 +1,15 @@ +function [theta, s] = mass(si, dt, C, M, L, P, Td, dTheta) +s = si; +if ~isstruct(si) + alpha = 1.0; + if Td > 0 + alpha = dt/Td; + end + s = struct('e', 0, 'a', alpha, 'x', 0, 'gain', 0.8); +end + +s.e = s.e * (1-((L*(0+dTheta))*dt)/(M*C)); +s.x = (1-s.a)*s.x + s.gain*s.a*P*dt; +s.e = s.e + s.x; +theta = s.e/(M*C); +endfunction diff --git a/matlab/mass_eval.m b/matlab/mass_eval.m new file mode 100644 index 0000000..1b5d3a2 --- /dev/null +++ b/matlab/mass_eval.m @@ -0,0 +1,30 @@ +function [theta, s] = mass_eval() + +s_mass = 0; +t_amb = 20; +dt = 1.0; +Td = 10; +N = 100; + +P_max = 3000; +P = 1000; +theta = t_amb; + + +for n=1:N, + duty = mod(n*dt/Td*P_max, P_max); + heat = (duty < P); + Pp = P_max * heat; + [theta, s_mass] = mass(s_mass, dt, 4190, 20, 0.1, Pp, 10, theta-t_amb); + theta_(n) = theta; + Pp_(n) = Pp; +end + +t = (0:N-1)*dt; + +subplot (2,1,1) +plot(t, theta_); grid; +subplot (2,1,2) +plot(t, Pp_); grid; + +endfunction