How combine line with contour plot?

24 vues (au cours des 30 derniers jours)
salim
salim le 25 Fév 2025
Réponse apportée : Aastha le 14 Mai 2025 à 6:38
i try to solve the problem i did but in graph i have some problem i did for 1 line by maple but i can't do it for two line and three line in maple althogh i think this kind of plot is taken from matlab can any one do this kind of graph
for the one line the shape of contour is
u(x, y, t) == 0.16e2 * (-5 * y - 8 * t + 5 * x) / (-(96 * y ^ 2) - (64 * t * y) - 0.64e2 * (t - x / 0.2e1) * y - 0.64e2 * (t - x / 0.2e1) ^ 2 - 0.75e2 - (16 * t ^ 2) - (16 * t * (-y - 2 * t + x)) - (4 * (-y - 2 * t + x) ^ 2))
and the line is
y == -x / 0.3e1 - sqrt(0.3e1) * sqrt(0.5e1) / 0.6e1;
for the 2 line and 6 shape of countour in fig2 d we have
u(x, y, t) == -2 * ((0.7933424e7 / 0.1891125e7+0.36508832e8 / 0.1891125e7*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) + (0.8059833e7 / 0.1092650e7+0.84073113e8 / 0.2185300e7*i) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) + (0.7933424e7 / 0.1891125e7-0.36508832e8 / 0.1891125e7*i) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) + (0.6e1 / 0.65e2-0.9e1 / 0.65e2*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) + (0.8059833e7 / 0.1092650e7-0.84073113e8 / 0.2185300e7*i) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.9e1 / 0.65e2-0.18e2 / 0.65e2*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.6e1 / 0.65e2+0.9e1 / 0.65e2*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.9e1 / 0.65e2+0.18e2 / 0.65e2*i) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x)) / ((0.9e1 / 0.65e2) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.27783e5 / 0.1625e4-0.11619e5 / 0.1625e4*i) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.135e3 / 0.52e2) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.74331e5 / 0.109265e6+0.118467e6 / 0.109265e6*i) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) + (0.74331e5 / 0.109265e6-0.118467e6 / 0.109265e6*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-0.2e1 / 0.3e1+i) * t + (0.5e1 / 0.9e1+0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1-i) * x) + (0.26e2 / 0.45e2) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-1+2*i) * t + (3+4*i) * y + t + (1-2*i) * x) + (0.27783e5 / 0.1625e4+0.11619e5 / 0.1625e4*i) * ((-1-2*i) * t + (3-4*i) * y + t + (1+2*i) * x) * ((-0.2e1 / 0.3e1-i) * t + (0.5e1 / 0.9e1-0.4e1 / 0.3e1*i) * y + t + (0.2e1 / 0.3e1+i) * x) + (0.126229597e9 / 0.50430e5))
and the two line are
eq1 = y == -0.9e1 / 0.28e2 * x - sqrt(0.3e1) * sqrt(0.15e2) / 0.14e2;
eq2 = y == -0.1e1 / (a__2 ^ 2 + 2 * a__2 + 1) * (x + sqrt(0.3e1) * sqrt(-(a__2 * (a__2 ^ 2 + 1) ^ 3)) / (a__2 ^ 2 + 1)
and i take this out from the fig 1 from maple

Réponses (1)

Aastha
Aastha le 14 Mai 2025 à 6:38
Hi @salim,
To overlay a contour plot with multiple lines, similar to the attached image, kindly refer to the steps mentioned below:
1. Use the "contour" function in MATLAB to plot the function "u(x,y,t)" as a function of "x" and "y" for a given value of "t". You can refer to the MATLAB code snippet below to do so:
% Plot contour
figure;
contour(x, y, u);
hold on;
Here, "x" and "y" are the coordinates at which the function "u(x,y,t)" is evaluated and stored in "u".
2. Use the "contour" function along with the "hold" function and "plot" function to overlay lines on the contour plot. The "hold on" command retains the plots in the current axes, ensuring that new plots do not delete existing ones. You can then add as many lines as required using the "plot" function. Below is a MATLAB code snippet for reference:
plot(x_line, y_vals, 'k', 'LineWidth', 2);
title('Contour Plot of u(x, y, t) with Overlaid Line');
xlabel('x');
ylabel('y');
axis equal;
grid on;
hold off;
You can add as many lines as needed by repeatedly using the "plot" function. Once all desired lines are added, use the "hold off" command to stop retaining the current axes for further plots.
The documentation links of "contour", "plot" and "hold" functions are mentioned below for your reference:
Hope this helps!

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by