Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Sep. 2022
Bearbeitet: Walter Roberson am 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 Kommentare
Image Analyst
Image Analyst am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by