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 Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by