Expression (equation)

Hello, how to define an expression, for example 1-e^(-At) where I can define and change parameters A and t and than figure changes of the curve in a graph.
Thanks

 Respuesta aceptada

Paulo Silva
Paulo Silva el 8 de Dic. de 2011

0 votos

Simplest version I can think of
t=0:0.1:100; % Time vector
A=0.1; % Value of A that you can change
plot(t,1-exp(-A(n)*t)) % Represent it on a figure
If you place the cursor on the value of A you can try several values using the Editor tools (look on the tools of your editor window - 1.0 + ... press those symbols and the script runs with a new value for A)
Just for fun here's a version using subplots
clf
t=0:0.1:10;
A=[0.01 0.1 0 1];
for n=1:4
subplot(2,2,n)
plot(t,1-exp(-A(n)*t))
title(['A=' num2str(A(n))])
end

9 comentarios

Jan
Jan el 8 de Dic. de 2011
Thanks for answer, but when I've tried it I got an error message in this: plot(t,1-exp(-A(n)*t)) % Represent it on a figure
Jan
Jan el 8 de Dic. de 2011
Thanks the subplots are working. Could you give me more explanation what means n in the line: plot(t,1-exp(-A(n)*t))
Sean de Wolski
Sean de Wolski el 8 de Dic. de 2011
It's the loop iterator that changes the value of A in each subplot in the bottom example. I it's a copy/paste error in the top (example)
Jan
Jan el 8 de Dic. de 2011
Is it possible to model it in the Simulink?
Paulo Silva
Paulo Silva el 8 de Dic. de 2011
Yes it is possible and simple, just play with the blocks, t is a Ramp and A is a Constant Source
Paulo Silva
Paulo Silva el 8 de Dic. de 2011
It took me about 2 minutes to do it, here's a few tips:
1- Start from the parenthesis expression A*t
2- To turn something negative just use a Gain block with value -1
3- Use the Math Function block for the exponential
Jan
Jan el 8 de Dic. de 2011
How could I use 2 kinds of source for one output if I use Ramp for t and Constant for A? I used Mux for signals, but in the output are two curves.
Sorry about that but could you make a list of blocks which to use.
Thanks again
Paulo Silva
Paulo Silva el 8 de Dic. de 2011
It's just basic math, you use the Product block with inputs A and t and connect that block output to the Math Function block
Jan
Jan el 8 de Dic. de 2011
thx :)

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 8 de Dic. de 2011

0 votos

And to add on to Paulo's example:
t=0:0.1:100; % Time vector
A=0.1;
y = 1-exp(-A*t); % Value of A that you can change
H = figure;
plot(t,y)
linkdata(H,'on');
shg;
pause(2) %watch the magic in 2 seconds
A = .8;
y = 1-exp(-A*t);
if you want it to automagically update when you change A or y.

3 comentarios

Paulo Silva
Paulo Silva el 8 de Dic. de 2011
nice one :)
Jan
Jan el 8 de Dic. de 2011
Thanks a lot Sean :)
Jan
Jan el 8 de Dic. de 2011
Is it possible to model it in the Simulink?

Iniciar sesión para comentar.

Categorías

Más información sobre Exponents and Logarithms en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Jan
el 8 de Dic. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by