Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
 
 
主题工具 显示模式
旧 2019-11-26, 03:41   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 solve the following nonlinear system with a discret input and compare to the linearization

enter image description here Please refer the problem on the attached link. Below is my code, but it doesn't give me the graph I wanted. The correct graph is shown on picture. I am new for matlab and any help is greatly appreciated.



function dydt = mix(t,y,c,d)  % function dydt is dy/dt with input t, y is either height or temperature
% y(1) is height, y(2) is temperature
% c = qc(t), d = qh(t)

dydt = [1/3*(c+d -(0.7*0.05*(19.6*y(1))^0.5)); 1/(3*y(1))*(c*(10-y(2))+d*(90-y(2)))]; % The first part % is dy(1)/dt = dh/dt and the second part after the semicolon is dy(2)/dt = dTt/dt.

>> tspan = linspace(0,100,100); % tspan from 0 to 100 with 100 steps
dydt = zeros(2,1); %for dh/dt and dT/dt
c =zeros(100,1);
d = zeros(100,1);
for i = 1:numel(tspan)
if i<=25
c(i) = 0.022; % c is qc(t) in the example
d(i) = 0.14; % d is qh(t) in the example
elseif (25< i)&& (i<=60)
c(i) =0.043;
d(i)= 0.14;
else
c(i) = 0.043;
d(i) = 0.105;
end
[t,y] = ode45(@(t,y)mix(t,y,c(i),d(i)), tspan, [1.10 81.5]);
plot(t,y(:,1)) % for height vs time graph
plot(t,y(:,2)) % Temperature vs time graph
drawnow;
end




More answer...
poster 当前离线   回复时引用此帖
 

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 05:22


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.