For Loop plot and zeros function
이전 댓글 표시
Having problems with my for loop plot at the bottom of the code. I'm trying to plot the 3rd column in C2 for the different values of the paramater k2. I think the problem is in the way I use the zeros function. I set the number of rows as height of C1 which is just calculating the same thing but for one value of the parameter k2 so I assumed it would be the same for C2. I'm trying to plot C2(:,3) for each k2 value that is. Can someone please help?
clear all; close all;
clc
%Initial Concentrations
CA0 = 0.13; %mol/L
CB0 = 0.1; %mol/L
Qoa = 0.0005; %L/s
Qob = 0.0005; %L/s
Q1 = Qob + Qoa;
CA1 = Qoa*CA0/Q1; %mol/L
CB1 = Qob*CB0/Q1; %mol/L
CC1 = 0;
CD1 = 0;
initCon = [CA1, CB1, CC1, CD1];
V = 10*10^-3;
k2 = 1;
%Residence Time
tau = V/Q1;
% Volume
tauRange = [0,tau]; %s
%ODE SOLVER
[tauRange, C1] = ode45(@diffpfr, tauRange, initCon, [], k2);
%PLOT PFR
figure (1)
plot(tauRange, C1,'Linewidth',1)
grid on
xlabel('Residence Time [s]')
ylabel('concentration [mol/L]')
legend('C_A', 'C_B', 'C_C', 'C_D')
%YIELD PROFILE
CcCao = C1(:,3)./CA0;
figure (2)
plot(tauRange, CcCao,'Linewidth',0.5)
grid on
xlabel('t_e_n_d')
ylabel('C_C/C_A_0')
% YIELD PLOT for 3 ratios
k2s = [10, 5 , 1];
X = zeros(height(C1), length(k2s));
for i = 1:numel(k2s)
[tauRange2, C2] = ode45(@diffpfr, tauRange, initCon, [], k2s(i));
X(i) = C2(:,3);
end
댓글 수: 1
Najeem Afolabi
2020년 12월 21일
편집: Najeem Afolabi
2020년 12월 21일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!