No BSD License  

Highlights from
Encoded Data Simulator

from Encoded Data Simulator by Bill Higley
A group of m-files that simulate encoded data

readhead(in)
%READHEAD(IN)
%   This function translates a NRZ signal into what a read head
%   from a magnetic disk would read.  It's values are -1, 0, and 1.
%
%   Although it is not necessary to illustrate each possibility,
%   because the array is initialized to zero, they are still
%   shown for clarity.

function out = readhead(in)

a=zeros(1,length(in));
a(1)=in(1);
for i=2:length(in)
    if in(i-1) == 0
        if in(i) == 0
            a(i) = 0;
        end
        if in(i) == 1
            a(i) = 1;
        end
    end
    if in(i-1) == 1
        if in(i) == 0
            a(i) = -1;
        end
        if in(i) == 1
            a(i) = 0;
        end
    end
end

out = a;

Contact us at files@mathworks.com