represent exponential function in app designer

2 次查看(过去 30 天)
How can I put the initial condition to the functions y1 and y2? Because the interface doesn't draw in the axes the function that I want and maybe it is due to the fact that my code doesn't have the initial condition, this is my code:
P = app.P.Value;
Q = app.Q.Value;
Xo = app.Xo.Value;
Yo =app.Yo.Value;
a = app.a.Value;
b = app.b.Value;
Ky = Yo-P/a;
Kx = Xo-Q/a;
C2 = (Ky.*sqrt(a/b)+Kx)/(2.*sqrt(a/b));
C1 = Ky-C2;
x = 0:0.2:100;
y1 = (- C1*sqrt(a/b)*exp(sqrt(a*b)*x) + C2*sqrt(a/b)*exp(-sqrt(a*b)*x)) + Q/b;
plot (app.Axes,x,y1,'k')
y2 = (C1*exp(sqrt(a*b)*x) + C2*exp(-sqrt(a*b)*x)) + P/a;
hold (app.Axes, 'on');
plot (app.Axes,x,y2,'g')
hold (app.Axes,'off')
thanks!

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-10-11
Hi Alvaro Mª Zumalacarregui Delgado,
It is my understanding that you want to add initial conditions to the functions y1 and y2. Here is an example for the same:
x = 1:10;
y1_initial = 0; % Intial y1 value
y2_initial = 4; % Intial y2 value
y1 = [y1_initial,cos(x)]; % Assigning intial y1 value
y2 = [y2_initial,sin(x)]; % Assigning intial y2 value
plot(y1,y2,'*');
In this example, “y1_initial” and “y2_initial” are the initial conditions for the functions “y1” and “y2”.
Best Regards,
Abhishek Chakram

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by