How can I set a condition that Vw = 0 when t = 0 in this code

1 visualización (últimos 30 días)
Clement
Clement el 18 de Mzo. de 2015
Comentada: Clement el 26 de Mzo. de 2015
How can I set a condition that Vw = 0 when t = 0 in this code
vib = 10; %
Vw = 0.1; %
t = [0 5 10 15 ];
Ta = [5]; %
Vb = vib + Vw*exp(t/Ta);
so that plot(t,Vb) starts at 10 and not 10 + exp(0)
Any help will be appreciated!

Respuestas (1)

Christiaan
Christiaan el 18 de Mzo. de 2015
Editada: Christiaan el 18 de Mzo. de 2015
Dear Clement,
In your function Vb = vib + Vw*exp(t/Ta), for t=0, Vb = vib + 0.1=10.1; There are many solutions if you like to set the Vb at 10. Here you can find two possible solutions:
Option 1
clc;clear all;close all
vib = 10; Vw = 0.1;
t = [0 5 10 15 ];
Ta = [5];
for i=1:length(t)
if t(i)==0
Vb(i) = 10;
else
Vb(i) = vib + Vw*exp(t(i)/Ta);
end
end
plot(t,Vb)
Option 2
clc;clear all;close all
vib = 10; Vw = 0.1;
t = [0 5 10 15 ];
Ta = [5];
Vb = vib + Vw*exp(t/Ta);
Vb = Vb - Vw;
plot(t,Vb)
Kind regards, Christiaan
  1 comentario
Clement
Clement el 26 de Mzo. de 2015
Hi Christian
Thanks for the help. It really did solve my problems.
Thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh 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