Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Why am I unable to plot all values in a for loop?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I am having difficulty plotting all values produced in a for loop. The program will only plot the last value, I'm not sure how to make the program not overwrite the previous values. Any help would be appreciated.
Voc_open = 12;
Voc_close = 5.3333;
Rt_open = 15;
Rt_close = 8.3333;
C = 0.01;
for T = 0: 0.01: 0.2
V_1 = Voc_close + (V_0 - Voc_close).*exp((-T./2)./(Rt_close.*C));
end
plot(T,V_1)
0 Commenti
Risposte (2)
James Tursa
il 22 Nov 2016
Rather than a loop, can you just do this?
T = 0: 0.01: 0.2;
V_1 = Voc_close + (V_0 - Voc_close).*exp((-T./2)./(Rt_close.*C));
0 Commenti
Deen Halis
il 22 Nov 2016
Hello Shayne, try this!
Voc_open = 12;
Voc_close = 5.3333;
Rt_open = 15;
Rt_close = 8.3333;
C = 0.01;
V_0 = 0.1;%%this was a missing variable
T1 = 0: 0.01: 0.2;
for i1 = 1:length(T1)
T = T1(i1);
V_1(i1) = Voc_close + (V_0 - Voc_close).*exp((-T./2)./(Rt_close.*C));
end
plot(T1,V_1)
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!