필터 지우기
필터 지우기

How do I create multiple parallel lines

조회 수: 7 (최근 30일)
Cliff Karlsson
Cliff Karlsson 2018년 9월 15일
댓글: jonas 2018년 9월 16일
How do I create parallel lines in a certain interval like in the picture? I am pretty sure I can use line() but I have not managed to understand how.

채택된 답변

Stephen23
Stephen23 2018년 9월 16일
편집: Stephen23 2018년 9월 16일
Plotting lots of lines is not the correct solution, you should use the grid command, or set the axes grid properties (e.g. adjust tick-mark positions, grid linestyle, grid color, grid transparency, etc.). The MATLAB documentation gives examples of how to adjust the grid lines:
This should get you started:
>> x = -10:0.1:10;
>> y = 100*sin(x);
>> plot(x,y,'-.')
>> ylim([-150,150])
>> set(gca,'YGrid','on') % Turn on the Y-grid. Also: color, linestyle, etc.
Produces this plot:
  댓글 수: 1
jonas
jonas 2018년 9월 16일
Cant believe I never realized you could customize the grid properties. The doc is pretty useful sometimes. +1

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 9월 15일
If you're not fussy about the way the lines look, you can simply call
grid on;
Also, if you want the x and y axis in there at the right place, instead of outside the plotting box, you can do
ax = gca
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';

카테고리

Help CenterFile Exchange에서 Formatting and Annotation에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by