필터 지우기
필터 지우기

Save values in the middle of a loop

조회 수: 2 (최근 30일)
Carlos
Carlos 2014년 3월 26일
답변: Marta Salas 2014년 3월 26일
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

채택된 답변

Marta Salas
Marta Salas 2014년 3월 26일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by