MATLAB Answers

0

how to write matlab code

I need to write matlab code to display number 20-50 except number that divisibility by 4 and 5 .How can i do it

  1 Comment

Alex Mcaulley on 3 Apr 2019
Thinking...
doc mod

Sign in to comment.

2 Answers

Answer by Andreas Bernatzky on 3 Apr 2019
 Accepted Answer

%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

  0 Comments

Sign in to comment.


Torsten
Answer by Torsten
on 3 Apr 2019

N=20:50
A = setdiff(N,N(mod(N,4)==0 & mod(N,5)==0))

  0 Comments

Sign in to comment.