please help me for , create a plot of the two functions sin(1.5x) and cos(2x) from 0 to 4pi
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Saleh
am 24 Sep. 2022
Kommentiert: Image Analyst
am 24 Sep. 2022
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);
y2=cosd(2x);
plot(x,y1);
hold on;
plot(x,y2);
Akzeptierte Antwort
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
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!