Azzera filtri
Azzera filtri

How to fix graph with for loop

3 visualizzazioni (ultimi 30 giorni)
sophp
sophp il 31 Gen 2018
Commentato: Star Strider il 31 Gen 2018
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?

Risposta accettata

Birdman
Birdman il 31 Gen 2018
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

Più risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by