MATLAB: How I make the plot like this

plot

캡처12.PNG
I want to draw this plot but I don't know how check the point (2pi,-2) and (6pi,4) (like that , the Solid line)
please help me…!!

Best Answer

This should get you started:
x = linspace(0, 10*pi); % Create Data

y = sin(x*0.3) + randn(size(x))/10; % Create Data
y2pi = interp1(x, y, 2*pi); % Interpolate To Find ‘y=2*pi’
y6pi = interp1(x, y, 6*pi); % Interpolate To Find ‘y=6*pi’
figure
plot(x, y)
hold on
plot(xlim, [0 0], '-k', 'LineWidth',2)
plot([0 2*pi], [1 1]*y2pi, '--k', [1 1]*2*pi, [0 1]*y2pi, '--k')
plot([0 6*pi], [1 1]*y6pi, '--k', [1 1]*6*pi, [0 1]*y6pi, '--k')
hold off
% set(gca, 'XAxisLocation','origin')
text(2*pi, y2pi, '2\pi', 'HorizontalAlignment','center', 'VerticalAlignment','bottom', 'FontSize',15)
text(6*pi, y6pi, '6\pi', 'HorizontalAlignment','center', 'VerticalAlignment','top', 'FontSize',15)
How I make the plot like this - 2019 01 03.png
You will have to experiment with your own data, and probably adjust the 'VerticalAlignment' values in the text calls.. However this will do all the calculations and the plotting.