Which is the Matlab equivalent to IDL's function bytscl? From IDL code I got

openr,1,"measures.dat"

nx=200
ny=100

data=fltarr(200,100)

readf,1,data

iimage,bytscl(data)
iimage,sobel(data)


but I can't afford IDL, even isn't near easy to buy a student licence in my contry. Anyway

In a Matlab transcript I wrote:

I=importdata('measures.dat');
nx=200; ny=100;
S=reshape(I,nx,ny);

figure(1)
image(S)

B = edge(S,'Sobel',0,'both') ;

figure(2)
image(B)


So how bytscl can be done?

Thanks.
Here is my answer, thanks for the comments, this version may be wrong but anyway the image data looks better.

function [ Y ] = bytscl( X )

m = min( X( : ) ); 
M = max( X( : ) ); 
Top = 255; 

    if isfloat( X ) 
    Fc = ( Top + 0.9999 )*( X - m )/( M - m );
    Y = cast( Fc, 'int8' );
    else
    Ic = ( Top + 1 )*( X - m - 1 )/( M - m ); 
    Y = cast( Ic, 'int8' ); 
    end 

end