Effacer les filtres
Effacer les filtres

please help me for , create a plot of the two functions sin(1.5x) and cos(2x) from 0 to 4pi

3 vues (au cours des 30 derniers jours)
On the same figure, create a plot of the two functions sin(1.5x) and cos(2x) from 0 to 4pi i will show you what i did but it still telling me that i have an error
x=0:4.*pi;
y1=sind(1.5x);
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
y2=cosd(2x);
plot(x,y1);
hold on;
plot(x,y2);

Réponse acceptée

Walter Roberson
Walter Roberson le 24 Sep 2022
Modifié(e) : Walter Roberson le 24 Sep 2022
y2=cosd(2x);
There are absolutely no places in MATLAB that permit implicit multiplication. If you want to multiply two things you must use .* (or sometimes * ) such as 1.5.*x
  3 commentaires
Image Analyst
Image Analyst le 24 Sep 2022
Great, then you probably did this:
x = linspace(0, 4 * pi, 1000);
y1 = sin(1.5 * x);
y2 = cos(2 * x);
% Display graph
plot(x, y1, 'b-', 'LineWidth',2);
hold on;
grid on;
plot(x, y2, 'r-', 'LineWidth',2);
fontSize = 14;
title("Trig functions", 'FontSize',fontSize)
xlabel("x", 'FontSize',fontSize)
ylabel("y", 'FontSize',fontSize)
legend('y1 = sin(1.5 * x)', 'y2 = cos(2 * x)')
so please click the "Accept this answer" link since Walter helped you realize you needed a * between the number and the x.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by