Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc;clear all;
- %%Manipulation: 1 => 0.5 , odd => 1, even =>0
- A=[100,270;313,21];
- disp(f(A));
- function [B]=f(A)
- [rows,columns]=size(A);
- B=zeros(rows,columns);
- for i=1:rows
- for j=1:columns
- if(A(i,j)==1)
- B(i,j)=0.5;
- else
- if(isEven(A(i,j))==1)
- B(i,j)=0;
- else
- B(i,j)=1;
- end
- end
- end
- end
- end
- function [y]=isEven(number)
- y=0;
- for i=2:fix(sqrt(number))
- if(mod(number,i)==0)
- y=1;
- break;
- end
- end
- end
Add Comment
Please, Sign In to add comment