How to fix graph with for loop
2 次查看(过去 30 天)
显示 更早的评论
I am trying to plot a graph to show me the operating curve of \tau with Y_B for different values of T. This is the code below:
t = 1:2:20;
T = 600:10:850;
for i=1:numel(T)
k1(i) = 1e7 .* exp(-12700 ./ T(i));
k2(i) = 5e4 .* exp(-10800 ./ T(i));
k3(i) = 7e7 .* exp(-15000 ./ T(i));
Y_B = (k1(i).*t.*(k1(i)+k3(i)))./(((k2(i).*t)+1).*(k1(i)+k3(i)).*(1+(t.*(k1(i)+k3(i)))));
plot(t, Y_B);
xlabel('Residence time, \tau / s')
ylabel('Yield of Maleic Anhydride ')
end
The graph produced is incorrect as it only has one operating curve. What is wrong with my code?
采纳的回答
Birdman
2018-1-31
Use hold on command:
t = 1:2:20;
T = 600:10:850;hold on;
for i=1:numel(T)
k1(i) = 1e7 .* exp(-12700 ./ T(i));
k2(i) = 5e4 .* exp(-10800 ./ T(i));
k3(i) = 7e7 .* exp(-15000 ./ T(i));
Y_B = (k1(i).*t.*(k1(i)+k3(i)))./(((k2(i).*t)+1).*(k1(i)+k3(i)).*(1+(t.*(k1(i)+k3(i)))));
plot(t, Y_B);
xlabel('Residence time, \tau / s')
ylabel('Yield of Maleic Anhydride ')
end
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!