SYNTAX MATLAB
조회 수: 1 (최근 30일)
이전 댓글 표시
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 ?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!