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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 5 de Mayo de 2020
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.
  2 comentarios
Yanjika O
Yanjika O el 5 de Mayo de 2020
Editada: Yanjika O el 5 de Mayo de 2020
Thank you Geoff. That is exactly what I was trying to explain. Let`s say I call those alternating flash as my first trial and what if I want to have the inter-trial period of complete black for 60 seconds between 2 consecutive trials?
Geoff Hayes
Geoff Hayes el 5 de Mayo de 2020
Just pause for sixty seconds between trials if you want all black:
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
set(hFill,'FaceColor',[0 0 0]);
pause(60);
end

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by