Can someone explain this simple matlab code to me
Afficher commentaires plus anciens
Can you please explain the following. New to matlab
Y = load('test.txt');
set = [Y(1:0,:);Y(101:end,:)];
1 commentaire
dpb
le 3 Août 2017
Start answered on the code as written syntactically; I'd posit it is a typo and was intended as something like
set = [Y(1:10,:);Y(101:end,:)];
in which case what the result is would be the first 10 and last M rows of the array Y. Often one sees such code to just later be able to visualize a small portion of a much larger array by taking a small section and the first and last few rows are generally the most interesting...a more general form would be to write
set = [Y(1:N,:);Y(end-(N-1):end,:)];
to pick up the first and last N records.
The comment on set is very important--do not alias builtin Matlab function names; trouble is bound to ensue.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!