MATLAB: How to make a flashing movie? Please suggest any approach without application of any specific toolbox.

videovideo processing

I am willing to make a video consists of 2 parts that are flashing and steady. The flashing could be in shape i.e circle or triangle. I created circle and dark with the following:
xCenter = 5;
yCenter = 6;
theta = 0 : 0.01 : 2*pi;
radius = 3;
x = radius * cos(theta) + xCenter;
y = radius * sin(theta) + yCenter;
plot(x, y);
fill(x,y,'k');
axis square;
xlim([0 10]);
ylim([0 12]);
axis equal;
set(gca,'Color','k')
And I want the flashing to continue for 17 seconds and steady for 17 seconds repeating 10 times each.

Best Answer

Yanjinsuren - do you really mean to create a movie (say with videowriter) or do you just want to have the circle alternate between black (on the black background) and white as per your requirements? To get you started on those, just keep the handle to the fill object, and change it's colour every one second. Something like
hFill = fill(x,y,'k');
axis square;
xlim([0 10]);
ylim([0 12]);
axis equal;
set(gca,'Color','k')
% use colour array [0 0 0] for black
color = [0 0 0];
set(hFill,'FaceColor',color);
for j = 1:10
for k = 1:17
% alternate between black [0 0 0] and white [1 1 1]
set(hFill,'FaceColor',mod(get(hFill,'FaceColor') + 1, 2));
pause(1.0);
end
pause(17);
end
Start with the above and try adding the video writer as needed.