video processing problem



Hello

Recently i start to learning video processing.
I wrote a simple code that convert video file from "RGB" to "Grayscale",
but when i trying to Play converted file by using "implay" i get errors.

I hope someone can guide me to solve the errors

I use MATLAB 2008b
The Class of the video file is : uint8

Code:
-------------------------------------------------------------------------------------
clc
clear
close all

rgb = 3;
gray = 1;

my_video = mmreader('CIMG1232.avi');
frameRate = get(my_video,'FrameRate');

nframes = get(my_video, 'NumberOfFrames');
I = read(my_video, 1);

video_p = zeros([size(I,1) size(I,2) gray nframes], class(I));

for i = 1 : nframes
singleFrame = rgb2gray(read(my_video, i));
video_p(:,:,:,i) = singleFrame;
end;

implay(video_p, frameRate);
----------------------------------------------------------------------------------------

Thanks in advance
.