Can someone explain this simple matlab code to me
Show older comments
Can you please explain the following. New to matlab
Y = load('test.txt');
set = [Y(1:0,:);Y(101:end,:)];
1 Comment
dpb
on 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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!