SYNTAX MATLAB
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Thomas
le 27 Juin 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!