I have used this code
I = imread('barbara.png');
noisyimage = RANDN(I);
I = im2double(imread('barbara.png'));
p = 0.2;% p between 0 and 1
noisyimage = (I + p*rand(size(I)))/(1+p);
imshow([I noisyimage]);
it does not work effectively when I tried to filter out the noisy pixels.