ploting 2d graph of a vector

6 visualizaciones (últimos 30 días)
adam hafzadi
adam hafzadi el 14 de Mayo de 2021
Editada: adam hafzadi el 15 de Mayo de 2021
Hey Friends,
I am trying to plot a vecotr (a solution of deritinal eqution) somting like those:
x(t)=Aexp(-3t)
y(t)=Bexp(2t)
Where A B are contecst ( so i am trying to see serveral function)
thanks a lot, Adam.

Respuesta aceptada

Chad Greene
Chad Greene el 14 de Mayo de 2021
You've pretty much got it, but you'll need to define a range of t values, and a value for the constants A, and B. You also need to use the * symbol for multiplication.
t = 0:0.1:10; % a range of t values from 0 to 100, steps of 0.1
A = 1;
B = 2;
x=A*exp(-3*t);
y=B*exp(2*t);
plot(t,x)
hold on
plot(t,y)
legend('x(t)','y(t)')
You may also want to set the vertical scale to log scale:
set(gca,'yscale','log')

Más respuestas (1)

adam hafzadi
adam hafzadi el 14 de Mayo de 2021
oh thank you , but when i am trying to do somtig more seresis its dosn`t work
t = -100:0.1:100; % a range of t values from 0 to 100, steps of 0.1
A = 1;
B = 2;
x=A*exp(-2*t)+B*t*exp(-2*t);
y=A*exp(2*t)+B*t*exp(-2*t)+B*exp(-2*t);
plot(t,x)
hold on
plot(t,y)
legend('x(t)','y(t)')
  2 comentarios
Chad Greene
Chad Greene el 14 de Mayo de 2021
Oh, yes, that's a quirk of Matlab when you multiply or divide vectors. By default Matlab tries to do a "cross multiplication". To do "dot multiplication" instead, just put a period (.) in front of every multiplication symbol, like this:
t = -100:0.1:100; % a range of t values from -100 to 100, steps of 0.1
A = 1;
B = 2;
x=A.*exp(-2.*t)+B.*t.*exp(-2.*t);
y=A.*exp(2.*t)+B.*t.*exp(-2.*t)+B.*exp(-2.*t);
plot(t,x)
hold on
plot(t,y)
legend('x(t)','y(t)')
adam hafzadi
adam hafzadi el 15 de Mayo de 2021
Editada: adam hafzadi el 15 de Mayo de 2021
thanks a lot!

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by