필터 지우기
필터 지우기

how to write matlab code

조회 수: 5 (최근 30일)
thatamon chantrasungnern
thatamon chantrasungnern 2019년 4월 3일
댓글: Image Analyst 2021년 7월 18일
I need to write matlab code to display number 20-50 except number that divisibility by 4 and 5 .How can i do it
  댓글 수: 2
Alex Mcaulley
Alex Mcaulley 2019년 4월 3일
Thinking...
doc mod
Image Analyst
Image Analyst 2021년 7월 18일
Do you want to print out, using fprintf()
  1. numbers that are not divisible by either 4 or 5
  2. numbers that are not divisible by 4 and also not divisible by 5?
Those are different things. Or do you mean that the numbers you print out must be divisible by 4 and/or 5. That is yet a different thing.

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

채택된 답변

Andreas Bernatzky
Andreas Bernatzky 2019년 4월 3일
%I need to write matlab code to display number 20-50 except number that divisibility by 4 and 5 .How can i do it
numbers=[];
for(a=20:1:50)
num=a;
numCheck4=mod(a,4);%check if there is a rest by division with 4
numCheck5=mod(a,5);%check if there is a rest by division with 5
if(numCheck4~=0&&numCheck5~=0)
numbers(end+1)=a;%pushback
end
end

추가 답변 (2개)

Torsten
Torsten 2019년 4월 3일
N=20:50
A = setdiff(N,N(mod(N,4)==0 & mod(N,5)==0))

Basher Alnour
Basher Alnour 2021년 7월 18일
Q1
numer = [2 -9/4 0.5];
d = conv([1 -0.5],[1 -1]);
deno = conv(d,[1 -0.25]);
[R P K] = residue(numer,deno)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by