I can't hold a lot graphs in an axes

1 view (last 30 days)
I don´t know why I can't se the 4 functions in the axe
this is the 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;
tiempo =app.t.Value;
%representación de la solución
Ky = Yo-P/a;
Kx = Xo-Q/b;
C2 = ((sqrt(a/b).*Ky)+Kx)/(2.*sqrt(a/b));
C1 = Ky-C2;
t = 0:0.2:tiempo;
x = - ((C1*sqrt(a/b)).*exp(sqrt(a*b).*t)) + ((C2*sqrt(a/b)).*exp(-sqrt(a*b).*t)) + Q/b;
plot (app.Axes,t,x,'k')
hold (app.Axes, 'on')
y = C1.*exp(sqrt(a*b).*t) + C2.*exp(-sqrt(a*b).*t) + P/a;
plot (app.Axes,t,y,'g')
% Runge-Kutta
tspan = [0 tiempo];
y0 = [app.Xo.Value; app.Yo.Value];
Q = app.Q.Value;
b = app.b.Value;
a = app.a.Value;
P = app.P.Value;
[t,y] = ode45(@(t,y) [P-a*y(2); Q-b*y(1)], tspan, y0); % x = y(1) % y = y(2)
hold (app.Axes,'on')
plot (app.Axes,t,y,'-o')
legend (app.Axes,{'y(t)','x(t)','x(t)R-K','y(t)R-K'})
hold (app.Axes,'off')
and the axes
  1 Comment
Star Strider
Star Strider on 3 Mar 2021
Check to see what the mising values are. They could be NaN, ±Inf, pure imaginary, or if divisions are not also element-wise when other operations are, simply be points and so would not plot without using a marker.
It is not possible to run the posted code.

Sign in to comment.

Answers (1)

Nipun
Nipun on 17 Apr 2024
Hi Alvaro,
I understand that you have plotted four plots using "axes" in MATLAB but are unable to see all four plots in the graphics. Without the plotted data points, it is not possible to comment on the exact reason for this observed behaviour.
However, there are two possible explanations for the invisible plots:
  1. Imaginary or NaN values: Please check your data to make sure all data points are real. Infinity values or NaN cannot be plotted on MATLAB axes. Pure imaginary values cannot be plotted with a defined x coordinate. For example when plotting (2, 0+5i) point, MATLAB plots (2,0) as it, by default considers the real component of each coordinate. However plotting (0+5i) will plot (0,5) with y-axis as the imaginary axis. For more information on plotting complex data points in MATLAB, refer to the following MathWorks documentation: https://in.mathworks.com/help/matlab/creating_plots/plot-complex-numbers.html
  2. Overlapping Plots: It may happen that some of the plots are just points or the data points for one plot are a subset of other. In these cases, the plots overlap on one another and MATLAB displays the last plotted data plot. I recommend trying disabling or commenting the currently visible plots to check if the former invisible plots become visible.
Hope this helps.
Regards,
Nipun

Categories

Find more on Line Plots 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!