필터 지우기
필터 지우기

Replace values of matrix by multiples

조회 수: 1 (최근 30일)
Mansour Al Asais
Mansour Al Asais 2020년 4월 5일
답변: David Hill 2020년 4월 7일
Write the instruction that replaces the values of A that are multiples of 10 by 999
I got this so far: A=A(mod(10,999)==0)
Im not sure of it though.
  댓글 수: 4
the cyclist
the cyclist 2020년 4월 5일
편집: the cyclist 2020년 4월 5일
Think of this as a two-step problem:
  1. identify the entries that are multiples of 10
  2. replace those with 999
You don't need to use the value 999 at all for the first part.
You are on the right track in using the mod function. But remember you that you are trying to find elements of A that are even multiples of 10. So, think of how to use A and 10 as your inputs.
Mansour Al Asais
Mansour Al Asais 2020년 4월 7일
(mod(a,10)==0)=999

댓글을 달려면 로그인하십시오.

답변 (1개)

David Hill
David Hill 2020년 4월 7일
A(mod(A,10)==0)=999;

카테고리

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