How do i create a "Cut" at origin?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Augustine Nashwan Aziz Al-Zebary
el 21 de Mzo. de 2021
Editada: Augustine Nashwan Aziz Al-Zebary
el 21 de Mzo. de 2021
Hello!
So i have coded a sine wave that looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/557377/image.png)
and the code is:
A = 5;
M = 0.8;
w = 1.2;
fi = 30;
t2 = 20;
firad = fi*pi/180;
t = linspace(0,t2,1000);
y = M + A*sin(w*t + firad);
plot(t,y,'r', 'LineWidth', 2);
mnimumy=min(y) - abs(min(y))*0.1;
mximumy=max(y) + abs(max(y))*0.1;
axis([0 t2 mnimumy mximumy]);
grid on;
So i want to create a cut at origin so that the wave will look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/557382/image.png)
where do i start? I tried changing the Miny on axis to 0 but it did not create the lines in between the waves like the picture above.
0 comentarios
Respuesta aceptada
Stephan
el 21 de Mzo. de 2021
A = 5;
M = 0.8;
w = 1.2;
fi = 30;
t2 = 20;
firad = fi*pi/180;
t = linspace(0,t2,1000);
y = M + A*sin(w.*t + firad);
% set all values y<0 to 0
y(y<0) = 0;
plot(t,y,'r', 'LineWidth', 2);
mnimumy=min(y) - abs(min(y))*0.1;
mximumy=max(y) + abs(max(y))*0.1;
axis([0 t2 mnimumy mximumy]);
grid on;
1 comentario
Augustine Nashwan Aziz Al-Zebary
el 21 de Mzo. de 2021
Editada: Augustine Nashwan Aziz Al-Zebary
el 21 de Mzo. de 2021
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!