Save values in the middle of a loop

1 vue (au cours des 30 derniers jours)
Carlos
Carlos le 26 Mar 2014
Hello, I'm coding an infinite loop that will be shooting photos every X minutes. The problem is that I need that it save the rows every time it has one, but the program only save in the workspace when the function has finished (I've put only 3 photos for seeing the result). Is there any way to keep updating every 30minutes in the workspace my matrix?
Thanks. Heres is my code:
function CalculaParticulas
vid = videoinput('winvideo', 1,'I420_1280x720');
set(vid,'ReturnedColorSpace','grayscale');
Densidad=1000;
VolumenMAX=pi*1000/(8E18);
VolumenMIN=pi*15.625/(8E18);
Caudal=0.01; %m3/min
i=1;
pause(2);%Dejamos 32 minutos de margen antes de empezar (en segundos)
while (1);
img{i} = getsnapshot(vid);
fname = ['img' num2str(i)];%que nombre le ponemos al archivo
imwrite(img{i}, fname, 'jpg');%guardar el archivo con formato
pause(2);%paramos 3minutos entre foto y análisis
img{i} = imread(['img' num2str(i)]);
% %imshow(img1)% Si queremos ver la imagen original
img2{i}=im2bw(img{i},graythresh(img{i}));
img2{i}=~img2 {i};
B=bwboundaries(img2 {i});
NumberOfParticle(i)=length(B);
% disp(['Hay ', num2str(NumberOfParticle), ' partículas'])
%hold on
%for k = 1:length(B)
%boundary = B{k};
%plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.2);
%end
Concentracion(i,1)=NumberOfParticle(i)*VolumenMAX*Densidad/Caudal
Concentracion(i,2)=NumberOfParticle(i)*VolumenMIN*Densidad/Caudal
Concentracion(i,3)=(Concentracion(i,1)+Concentracion(i,2))/2
% assignin('base','Concentracion',Concentracion);
i=i+1;
pause(5); %esperamos 27'
if i==3;
break;
end
end

Réponse acceptée

Marta Salas
Marta Salas le 26 Mar 2014

Plus de réponses (0)

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by