SYNTAX MATLAB
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Thomas
am 27 Jun. 2012
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!