Can someone explain why no plot is showing up?

1 visualización (últimos 30 días)
Westin Messer
Westin Messer el 11 de Dic. de 2018
Editada: madhan ravi el 11 de Dic. de 2018
Hello,
I wrote this matlab script where I am trying to plot the time 't' vs. the variable 'c' but for some reason no line is showing up. I know there is data for both of these so I'm confused as to what is going on. Can anyone see what I am doing wrong? Thanks!
V_p = 0.9;
k_f = 1.11;
J_er = 0.02;
K_p = 0.1;
gamma = 5.5;
c_t = 2;
p = 0.5;
k1 = 400;
k2 = 0.2;
k3 = 400;
k4 = 0.2;
k5 = 20;
k_1 = 52;
k_2 = 0.21;
k_3 = 377.2;
k_4 = 0.029;
k_5 = 1.64;
K1 = 0.13;
K2 = 1.05;
K3 = 0.943;K4 = 0.145;
K5 = 0.082;
c =0;
c_e=0;
J_serca=0;
P_0=0;
y = 1;
dc=0;
dc_e = 0;
dy = 0;
dt=0.1;
i=0;
for t=0:dt:100;
i = i+1;
J_serca = (V_p*c*c)/(K_p*K_p+c*c);
P_0 = (p*c*(1-y)/((p+K1)*(c+K5)))*(p*c*(1- y)/((p+K1)*(c+K5)))*(p*c*(1-...
y)/((p+K1)*(c+K5)));
c_e = (c_t-c)*gamma;
dc = (k_f*P_0+J_er)*(c_e-c)-J_serca;
dy = (((k_4*K1*K2+k_2*p*K4)*c)/(K4*K2*(p+K1)))*(1-y)-...
((k_2*p+k_4*K3)/(p+K3))*y;
c=c+dc*dt;
y=y+dy*dt;
data(i,1)= t;
data(i,2)= c;
data(i,3)= y;
plot(t,c)
end

Respuesta aceptada

madhan ravi
madhan ravi el 11 de Dic. de 2018
Editada: madhan ravi el 11 de Dic. de 2018
EDITED
You don‘t get a plot because your plotting singular points in each iteration and without marker matlab assumes it‘s a line thereby getting empty plot
V_p = 0.9;
k_f = 1.11;
J_er = 0.02;
K_p = 0.1;
gamma = 5.5;
c_t = 2;
p = 0.5;
k1 = 400;
k2 = 0.2;
k3 = 400;
k4 = 0.2;
k5 = 20;
k_1 = 52;
k_2 = 0.21;
k_3 = 377.2;
k_4 = 0.029;
k_5 = 1.64;
K1 = 0.13;
K2 = 1.05;
K3 = 0.943;K4 = 0.145;
K5 = 0.082;
c =0;
c_e=0;
J_serca=0;
P_0=0;
y = 1;
dc=0;
dc_e = 0;
dy = 0;
dt=0.1;
i=0;
for t=0:dt:100;
i = i+1;
J_serca = (V_p*c*c)/(K_p*K_p+c*c);
P_0 = (p*c*(1-y)/((p+K1)*(c+K5)))*(p*c*(1- y)/((p+K1)*(c+K5)))*(p*c*(1-...
y)/((p+K1)*(c+K5)));
c_e = (c_t-c)*gamma;
dc = (k_f*P_0+J_er)*(c_e-c)-J_serca;
dy = (((k_4*K1*K2+k_2*p*K4)*c)/(K4*K2*(p+K1)))*(1-y)-...
((k_2*p+k_4*K3)/(p+K3))*y;
c=c+dc*dt;
y=y+dy*dt;
data(i,1)= t;
data(i,2)= c;
data(i,3)= y;
end
plot(data(:,1),data(:,2),'-k','Linewidth',2)
  2 comentarios
Westin Messer
Westin Messer el 11 de Dic. de 2018
Thanks! do you know how I change the marker to just be a line instead of circles?
madhan ravi
madhan ravi el 11 de Dic. de 2018
Editada: madhan ravi el 11 de Dic. de 2018
So just plot outside the loop '-' as marker read https://in.mathworks.com/help/matlab/ref/linespec.html for better understanding of markers
, see edited answer

Iniciar sesión para comentar.

Más respuestas (1)

Cris LaPierre
Cris LaPierre el 11 de Dic. de 2018

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by