vector manipulation by a function

1 次查看(过去 30 天)
Dear all; please how to trait a A vector (eliminate the elements stocked in B vector by order)
A = [10 52 33]
B = [3]
ii = num2cell([1]*setdiff(1:length(A),B(:)'),1);
out = A(ii{:});
i get out = 52 so i must get out = 10 52 (eliminate the third element)

采纳的回答

Image Analyst
Image Analyst 2017-4-8
编辑:Image Analyst 2017-4-8
Don't do that complicated stuff with cell arrays, etc. If you want to delete the third element (or ALL the elements listed in B), then simply do
out = A; % Initialize an output variable - make a copy of A.
out(B) = []; % Delete indexes given in B

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by