⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proc_sys.m

📁 Matlab学习课件
💻 M
字号:
function xdot = proc_sys(trel,x)
%Simulation of the actual process system
% Note that in the mode used here, the time given is relative to the time at the
% beginning of this time step. That is because the structure of the odeset()
% parameters forces that in order to set output option to end of step only!
% State variables:
%	x(1)	carriage position, x_car
%	x(2,3,4)	mass of component A in tanks1,2,3; va1, va2 ,va3
%	x(5,6,7)	mass of component B in tanks 1,2,3; vb1, vb2, vb3
%	x(8,9,10)	temperature in tanks 1,2,3; temp1, temp2, temp3

procglbl	% Get global variables

xdot = zeros(10,1);

ncall = ncall + 1;
time = tstep + trel;	% Actual time
x_car = x(1);
va1 = x(2);
va2 = x(3);
va3 = x(4);
vb1 = x(5);
vb2 = x(6);
vb3 = x(7);
temp1 = x(8);
temp2 = x(9);
temp3 = x(10);
xdot(1) = v_car;	% Simple carriage model: velocity is set immediately by command

% Find out where the carriage is so flow is sent to correct tank
flowa1=0;flowb1=0;flowa2=0;flowb2=0;flowa3=0;flowb3=0;	%Default
if abs(x_car - xt1) < 0.5, flowa1 = flow_a; flowb1 = flow_b;
elseif abs(x_car - xt2) < 0.5, flowa2 = flow_a; flowb2 = flow_b; 
elseif abs(x_car - xt3) < 0.5, flowa3 = flow_a; flowb3 = flow_b;
end

pa1 = va1 / (va1 + vb1);	% Proportion of A in tank
pa2 = va2 / (va2 + vb2);
pa3 = va3 / (va3 + vb3);
fa1 = pa1 * flow1out;
fa2 = pa2 * flow2out;
fa3 = pa3 * flow3out;
fb1 = (1 - pa1) * flow1out;
fb2 = (1 - pa2) * flow2out;
fb3 = (1 - pa3) * flow3out;
xdot(2) = flowa1 - fa1;
xdot(3) = flowa2 - fa2;
xdot(4) = flowa3 - fa3;
xdot(5) = flowb1 - fb1;
xdot(6) = flowb2 - fb2;
xdot(7) = flowb3 - fb3;
xdot(8) = (heat1 + flowa1 * ca * temp_a + flowb1 * cb * temp_b ...
	- (fa1 * ca + fb1 * cb) * temp1) / (ca * pa1 + cb * (1 - pa1));
xdot(9) = (heat2 + flowa2 * ca * temp_a + flowb2 * cb * temp_b ...
	- (fa2 * ca + fb2 * cb) * temp2) / (ca * pa2 + cb * (1 - pa2));
xdot(10) = (heat3 + flowa3 * ca * temp_a + flowb3 * cb * temp_b ...
	- (fa3 * ca + fb3 * cb) * temp3) / (ca * pa3 + cb * (1 - pa3));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -