필터 지우기
필터 지우기

replacing items in a matrix

조회 수: 2 (최근 30일)
CLARK KENDRICK GO
CLARK KENDRICK GO 2018년 4월 8일
답변: Walter Roberson 2018년 4월 8일
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