I'm trying to plot simple horizontal and vertical lines in MATLAB to draw an MMI device design.
Here is part of the code:
line([0 L], [W/2 W/2]);
line([0 L], [-W/2 -W/2]);
line([0-dz 0], [-a -a]);
The first two lines work as expected. However, when I add the third line, it overwrites one of the previous lines, and moves one of the other lines to zero.
What can I do to fix this overwriting process?
Thanks.

 채택된 답변

Star Strider
Star Strider 2019년 2월 23일

1 개 추천

This works for me:
L = 42;
W = 42;
dz = 13;
a = pi;
figure
line([0 L], [W/2 W/2]); % Horizontal Line
line([0 L], [-W/2 -W/2]); % Horizontal Line
line([-a -a], [0-dz 0]); % Vertical Line
NOTE — If you want to plot the last one as a vertical line, you need to switch the order of the arguments (as I did here).

댓글 수: 2

Austin Patton
Austin Patton 2019년 2월 23일
Thanks, after testing your code I figured out what was wrong. I forgot to use micrometer units for my "a" variable, so anything that had an "a" in it messed up the scaling.
Star Strider
Star Strider 2019년 2월 23일
편집: Star Strider 2019년 2월 23일
As always, my pleasure.

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

추가 답변 (0개)

태그

질문:

2019년 2월 23일

편집:

2019년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by