Can someone explain this simple matlab code to me
Ältere Kommentare anzeigen
Can you please explain the following. New to matlab
Y = load('test.txt');
set = [Y(1:0,:);Y(101:end,:)];
1 Kommentar
dpb
am 3 Aug. 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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!