please help me for , create a plot of the two functions sin(1.5x) and cos(2x) from 0 to 4pi
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Saleh
el 24 de Sept. de 2022
Comentada: Image Analyst
el 24 de Sept. de 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);
Respuesta aceptada
Walter Roberson
el 24 de Sept. de 2022
Editada: Walter Roberson
el 24 de Sept. de 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 comentarios
Image Analyst
el 24 de Sept. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!