![]() |
solve the following nonlinear system with a discret input and compare to the linearization
<p><a href="https://i.stack.imgur.com/rkYDq.png" rel="nofollow noreferrer">enter image description here</a> 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.</p>
<pre><code>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 </code></pre> [url=https://stackoverflow.com/questions/59038975/solve-the-following-nonlinear-system-with-a-discret-input-and-compare-to-the-lin]More answer...[/url] |
所有时间均为北京时间。现在的时间是 23:28。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.