필터 지우기
필터 지우기

How to change values of elements in array at rows that meet a condition?

조회 수: 1 (최근 30일)
Mason Scott
Mason Scott 2015년 6월 26일
답변: Azzi Abdelmalek 2015년 6월 26일
For example if I have array
A = [1;2;3;4;5;6;7;8]
and I want to change all values at rows that are divisible by 2 to 0 to produce
A = [1;0;3;0;5;0;7;0]
How would I accomplish this?

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 6월 26일
A(mod(A,2)==0)=0

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by