Subplot in ODE45

1 回表示 (過去 30 日間)
Hüseyin Cagdas Yatkin
Hüseyin Cagdas Yatkin 2019 年 11 月 26 日
回答済み: Hüseyin Cagdas Yatkin 2019 年 11 月 27 日
Hi guys, I try to subplot with changing 'd' value. How should I do it?
function hw5q2b
ode45(@b2,[0 2],[130 10 5]);
xlabel('time (mins)')
ylabel('concentration (mg/L)')
end
function y = b2(~,C)
k1 = 0.56; %1/h
k2 = 0.28; %1/h
Q = 300/1000; %m^3/h-Flowrate
d = [0.20 0.30 0.50]; % m, given diameters
for i = 1:length(d)
A = pi*(d(i)^2); %m^2, area
v = Q/A ; %m/h
y(1) = -(k1*C(1))/v;
y(2) = (k1*C(1)-k2*C(2))/v;
y(3) = (k2*C(2))/v;
y = y(:);
end
end

採用された回答

Stephan
Stephan 2019 年 11 月 26 日
編集済み: Stephan 2019 年 11 月 26 日
d = [0.20 0.30 0.50];
for ii = 1:numel(d)
sol(ii)=ode45(@(t,C)b2(t,C,d(ii)),[0 2],[130 10 5]);
t{:,ii}=sol(ii).x';
y{:,:,ii}=sol(ii).y';
subplot(3,1,ii)
plot(t{:,ii},y{:,:,ii})
end
function y = b2(~,C,d)
k1 = 0.56; %1/h
k2 = 0.28; %1/h
Q = 300/1000; %m^3/h-Flowrate
A = pi*d^2; %m^2, area
v = Q/A ; %m/h
y(1) = -(k1*C(1))/v;
y(2) = (k1*C(1)-k2*C(2))/v;
y(3) = (k2*C(2))/v;
y = y(:);
end

その他の回答 (1 件)

Hüseyin Cagdas Yatkin
Hüseyin Cagdas Yatkin 2019 年 11 月 27 日
Thanks a lot! It will be very helpful.

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by