Can someone explain this simple matlab code to me
显示 更早的评论
Can you please explain the following. New to matlab
Y = load('test.txt');
set = [Y(1:0,:);Y(101:end,:)];
1 个评论
dpb
2017-8-3
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!