represent exponential function in app designer

1 view (last 30 days)
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!

Answers (1)

Abhishek Chakram
Abhishek Chakram on 11 Oct 2023
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

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!