What does '...' mean in MATLAB?

조회 수: 169 (최근 30일)
Douglas Alves
Douglas Alves 2014년 5월 13일
댓글: Douglas Alves 2014년 5월 13일
I came across this script and I've seen h = ... what does it mean?
axis(1.2*[-1 1 -1 1])
axis square
box on
hold on
x = 0;
y = 1;
h = ...
n = 2*pi/h;
plot(x,y,.)
for k = 1:n
x = x + h*y;
y = y - h*x;
plot(x,y,.)

채택된 답변

Benjamin Avants
Benjamin Avants 2014년 5월 13일
The three dots '...' tell matlab that the code on a given line continues on the next line.
It is used so that command lines don't stretch out too long to print or read easily.
ex.
set(1,'Position',[0,0,1,1],'Tag','MyTag','Color', ...
[.94,.94,.94]);
This code is interpreted as a single set command with multiple parameters.
In the script you posted, the line in question would actually be interpreted like this:
h = n = 2*pi/h;
which should cause an error.
Whoever wrote the script must be using it as a place holder for something else.
  댓글 수: 1
Douglas Alves
Douglas Alves 2014년 5월 13일
Yes! There's an error. I was wondering why. Thank you Benjamin

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

추가 답변 (1개)

per isakson
per isakson 2014년 5월 13일
편집: per isakson 2014년 5월 13일
doc on Special Characters says
Continuation. Three or more periods [...] at the end of a line continue the current function on the next line. Three or more periods before the end of a line cause the MATLAB® software to ignore the remaining text on the current line and continue the function on the next line. This effectively makes a comment out of anything on the current line that follows the three periods. For an example, see Continue Long Statements on Multiple Lines.
  댓글 수: 1
Douglas Alves
Douglas Alves 2014년 5월 13일
Thank you Isakson, I didn't know the command for that. Thanks

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

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by