Saturday, August 20, 2005

tips of matlab from former post

1. x = x(end:-1:1); %reverse a vector

2. x( 3:5 ) = []; % remove part of the vector

3. fprintf('Some Text'); %Output a string without carriage return: some text>>

4. m = min(x(:)); M = max(x(:));

x = (b-a) * (x-m)/(M-m) + a;
%Rescale the entries of a vector x so that it spans [a,b]

5. [,I] = sort(abs(x(:)));

x( I(1:end-n) ) = 0;
%Keep only the n biggest coefficients of a signal x (set the others to 0).

6. Resize an image M (new size is (p1,q1)).

[p,q] = size(M); % the original image

[X,Y] = meshgrid( (0:p-1)/(p-1), (0:q-1)/(q-1) ); % new sampling location

[XI,YI] = meshgrid( (0:p1-1)/(p1-1) , (0:q1-1)/(q1-1) );

M1 = interp2( X,Y, M, XI,YI ,'cubic');
% the new image

7. Compute the PSNR between to signals

d = mean( mean( (x-y).^2));

m = max( max(x(:)),max(y(:))

PSNR = 10*log10( m/d );

No comments:

Post a Comment