Write a function to perform binary shift right operation You

Write a function to perform binary shift right operation. Your function will accept a binary vector (a sequence of 0s and 1s), and will shift the digits in your binary vector one digit to the right. The function will replace the first digit with one 0. Example: Assume input x=[1 0 1 1 0 0 0 1], then the output of your function should be y =[0 1 0 1 1 0 0 0]. Solution function y = binShiftRight(x) y = x; end

Solution

ans)

Matlab code

---------------------------

function y=binShiftRight(x)

if sum(x<0) || sum(x>1)

error(\'Given Vector is not a binary vector\');

end

y=[0 x(1:end-1)];

end

-------------------------------------------

 Write a function to perform binary shift right operation. Your function will accept a binary vector (a sequence of 0s and 1s), and will shift the digits in you

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site