Afficher dans une même fenêtre les fonctions $cos(x)$, $sin(x)$ entre $0$ et $2 \pi$ (en utilisant l’instruction hold on).
Ajouter maintenant des labels sur les axes, un titre et une légende au graphique généré.
x = [0:0.1:2*pi];
% Affichage des courbes
hold on;
plot(x, cos(x));
plot(x, sin(x));
% Legende, titre et labels
title("Coubres cosinus et sinus entre 0 et 2pi");
xlabel("x");
ylabel("y");
legend("cosinus","sinus");
On cherche à obtenir une représentation graphique de la fonction $f(x) = \exp(-x) . \sin(4x)$ sur l'intervalle [0,2].
x = linspace(0,2*pi,101);
f = exp(-x) .* sin(4*x);
hold on;
plot(x, f);
axis([0 2])
title("f(x) = exp(-x) * sin(4x)");
xlabel("x");
ylabel("y");
legend("f(x)"),
hold off;
x = linspace(-1,1,1000);
f = exp(-x) .* sin(4*x);
g = x.^2;
h = x.^2 .* sin(x) .* exp(-x);
figure();
subplot(2,2,1);
plot(x, f, "k+");
axis([-1 1])
title("f(x) = exp(-x) * sin(4x)");
xlabel("x");
ylabel("y");
legend("f(x)"),
subplot(2,2,2);
plot(x, g, "r*");
axis([-1 1])
title("g(x) = x²");
xlabel("x");
ylabel("y");
legend("g(x)"),
subplot(2,2,3);
plot(x, h, "go");
axis([-1 1])
title("h(x) = x² * sin(x) * exp(-x)");
xlabel("x");
ylabel("y");
legend("h(x)");
Ecrire un programme qui trace le « papillon de T. Fay », courbe paramétrée en coordonnées polaires pour le paramètre theta variant de $0$ à $2\pi$
$$ r = \exp(\cos(\theta)) - 2\cos(4 \theta) $$
<aside> ❗ Nota : penser à repasser en coordonnées cartésiennes avant d’afficher la courbe !
</aside>
% Calcul de la fonction
theta = linspace(0,2*pi,101);
r = exp(cos(theta)) - 2 * cos(4.*theta);
% Calcul des coordonnées cartesiennes
x = r.*cos(theta)
y = r.*sin(theta)
% OU
[x, y] = pol2cart(theta, r);
% Affichage
plot(x, y)
xlabel("x");
ylabel("y");
title("Papillon de T.Fay");
axis equal;