replacing items in a matrix

2 次查看(过去 30 天)
I have a vector:
A = 6:2:19;
and
r = 10;
I want to replace the element in A which corresponds to r with nothing.
So I want my new vector A = [6, 8, 12, 14, 16, 18];
How do I do that?

采纳的回答

Walter Roberson
Walter Roberson 2018-4-8
A(A==r) = [];
If r is a vector or array then
A(ismember(A,r)) = [];

更多回答(1 个)

Sumit Chaudhary
Sumit Chaudhary 2018-4-8
clc; clear all; close all;
A = 6:2:19; r = 10;
A1 = A(find(A~=r))

类别

Help CenterFile Exchange 中查找有关 Direct Search 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by