Matlab - Problemas para graficar.

 
Vista:

Problemas para graficar.

Publicado por orphen (6 intervenciones) el 07/08/2015 19:29:18
Hola, que tal. Quisiera saber si me pueden ayudar con lo siguiente, resulta que tengo el siguiente código en el cual tengo una función que depende del tiempo, de modo que para ciertos intervalos de tiempo las variables que contiene esta función cambian, hasta ahí todo bien, pero el problema llega cuando quiero graficarlo, no se por qué motivo no está mostrando nada. Sería de gran ayuda si me pueden orientar, de antemano muchas gracias. Saludos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
for t=0:(delta):0.2
 
    tiempo=t+delta;
 
    if t>=0 && t<=0.05
      c1= 40;
      c2= 0;
    end
    if t>0.05 && t<=0.2
      c1= 0;
      c2= 2;
    end
    if t>0.2
      c1=0;
      c2=0;
    end
   ask=(c1*t)+c2;
 
end
 plot(tiempo,ask)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Royeth
Val: 3.309
Plata
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Problemas para graficar.

Publicado por Royeth (1818 intervenciones) el 07/08/2015 21:23:47
bueno tienes errores en el planteamiento , aunque este no sería la forma de hacerla lo más corto posible aquí está la corrección que debes hacer :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tiempo=0:delta:0.2; k=1;
for t=0:delta:0.2
if t>=0 && t<=0.05
c1= 40;
c2= 0;
end
if t>0.05 && t<=0.2
c1= 0;
c2= 2;
end
if t>0.2
c1=0;
c2=0;
end
ask(k)=(c1*t)+c2;
k=k+1;
end
plot(tiempo,ask)

Saludos
https://www.facebook.com/royethmatlab/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problemas para graficar.

Publicado por orphen (2 intervenciones) el 07/08/2015 22:49:32
Gracias por la respuesta, solo que me equivoque al traspar una aprte del código. Delta tiene un valor constante.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
delta=0.00625;
 
for t=0:t+delta:0.2;
 
    tiempo=t+delta;
    if tiempo>=0 && tiempo<=0.05
      c1= 40
      c2= 0
    end
    if tiempo>0.05 && tiempo<=0.2
      c1= 0
      c2= 2
    end
    if tiempo>0.2 && tiempo<=0.4
      c1= -20
      c2= 6
    end
  ask=(c1*tiempo)+c2;
 
end
  plot(t,ask)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Royeth
Val: 3.309
Plata
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Problemas para graficar.

Publicado por Royeth (1818 intervenciones) el 08/08/2015 01:08:40
pues es lo mismo , sería :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
delta=0.00625;
t=0:delta:0.2;
k=1;
for tiempo=0:delta:0.2;
if tiempo>=0 && tiempo<=0.05
c1= 40;
c2= 0;
end
if tiempo>0.05 && tiempo<=0.2
c1= 0;
c2= 2;
end
if tiempo>0.2 && tiempo<=0.4
c1= -20;
c2= 6;
end
ask(k)=(c1*tiempo)+c2;
k=k+1;
end
plot(t,ask)


https://www.facebook.com/royethmatlab
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Problemas para graficar.

Publicado por orphen (2 intervenciones) el 08/08/2015 03:36:03
Muchas gracias por tomarte el tiempo de responder. Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar