SYNTAX MATLAB

조회 수: 2 (최근 30일)
Sara
Sara 2012년 6월 27일
y1 = x(2:n) ;
t1 = n*dt - (2*dt:dt:n*dt)
could anyone tell me what is the meaning of the these commands? The syntax of MATLAB, I mean, what does do x(2:n) and n*dt - (2*dt:dt:n*dt) ? x times (2:n)? and the second one sub an 4 dimension array from a scalar ?

채택된 답변

Thomas
Thomas 2012년 6월 27일
Eg.
x=1:20; %i.e x=1 2 3.... 20
n=5; % assign value of 5 to n
y1 = x(2:n) % get second to nth (5th )value in x and put it in y1
Output of above
y1 =
2.00 3.00 4.00 5.00
dt=1; %assign value of 1 to dt.. you can give any value
t1 = n*dt - (2*dt:dt:n*dt);
frist term n*dt %multiply n (scalar) by dt a scalar
n*dt
ans =
5.00
second term 2*dt:dt:n*dt % range twice dt to ntimes dt witht a difference of dt for above case 2*1:1:5*1 i.e (2:1:5)
2*dt:dt:n*dt
ans =
2.00 3.00 4.00 5.00
ti=sub first term (scalar) -second term (array) (5-2, 5-3, 5-4, 5-5)
t1 = n*dt - (2*dt:dt:n*dt)
t1 =
3.00 2.00 1.00 0
  댓글 수: 1
Sara
Sara 2012년 7월 4일
what is the type of x, here? what is the meaning of dt in (2*dt:dt:n*dt)

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by