Plotting using fimplicit and plot in the same figure
이전 댓글 표시
I copied my code below. The issue I am having is in the second figure. I want to plot two different curves/lines, one using fimplicit and the other using plot in the same figure. However, it only plots the fimplicit statement and seems to completely ignore the plot statement, despite the fact that it works fine in the first figure. I'm not sure what to do. I thought I was using hold on and hold off correctly. Any insights would be appreciated!
[t, y] = ode45(@(t,y) (t-exp(-t))/(y+exp(y)), [1.5 0], 0.5);
fprintf('\nWhen t = 0, y is approximately %d.\n', y(t == 0))
fprintf('When t = 1, y is approximately %d.\n', y(t < 1.02 & t > 0.98))
told = t;
yold = y;
[t, y] = ode45(@(t,y) (t-exp(-t))/(y+exp(y)), [1.5 2.1], 0.5);
fprintf('When t = 1.8, y is approximately %d.\n', y(t < 1.81 & t > 1.79))
fprintf('When t = 2.1, y is approximately %d.\n', y(t == 2.1))
t = [told t];
y = [yold y];
figure(1);
plot(t,y, 'r');
xlim([0 2.1]);
grid on
grid minor
hold off
syms z x
f(x, z) = 2*exp(z) + z^2 - 2*exp(-x) - x^2;
c = f(1.5, 0.5);
figure(2);
plot(t, y, 'rx');
hold on
fimplicit(f-c, [0, 2.1, -1, 2], 'b');
grid on
grid minor
hold off
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!