how do I change the abscissa (x -axis) of a cosine wave plot to show degrees
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sean
el 11 de Dic. de 2025 a las 1:18
Comentada: Sean
el 11 de Dic. de 2025 a las 2:32
this is my current code,
x= 0:pi/100:4*pi;
y1 = cos(x);
A= 3;
B= 1.5;
C = pi/2;
D = -3;
y2 = A*cos(B*x+C)+ D;
D = rad2deg(4*pi)
xlim([0 D])
plot(x,y1,'-r',x,y2,'--b')
xlabel('Angle (θ) [°]')
ylabel('funtion value')
grid
legend('','y = Acos(BΘ + C) + D')
On side note I would be able to prompt the user to imput the varibles A, B, C, ana D,
these are my results:

this is what I want the graph to kinda look like

0 comentarios
Respuesta aceptada
Paul
el 11 de Dic. de 2025 a las 1:27
Editada: Paul
el 11 de Dic. de 2025 a las 2:15
Change the plot command so that the independent variables are in deg. Or define x in terms of deg and then use cosd to compute y1 and y2 with B and C modified appropriately. Also, can use tex to get theta in the labels and legend if you think that looks any better. And put the xlim after the plot command.
x= 0:pi/100:4*pi;
y1 = cos(x);
A= 3;
B= 1.5;
C = pi/2;
D = -3;
y2 = A*cos(B*x+C)+ D;
D = rad2deg(4*pi);
%xlim([0 D])
plot(rad2deg(x),y1,'-r',rad2deg(x),y2,'--b')
xlim([0,D])
xlabel('Angle (\theta) [°]')
ylabel('function value')
grid
legend('','y = Acos(B\theta + C) + D')
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
