Matlab - define delay time in a for cylce in matlab

 
Vista:

define delay time in a for cylce in matlab

Publicado por Gabriel (1 intervención) el 07/04/2013 21:20:28
Hi, I need to do matlab data acquisition, but I need control the rate and amount of data stored in a vector. I made a "for cycle", but I need that the cycle takes place each unit time defined, up to the total acquisition time. I mean, if t=1, I need 500 samples stored in a second, one each 0.002ms. How I can do that?. Thanks!

clc
t=1;
v1=zeros(1,500*t);
delete(instrfind({'Port'},{'COM3'}))
s = serial('COM3');
set(s,'BaudRate',9600);
s.inputbufferSize = 10000;

delay= wait time = frecuency of data
fopen(s);

for i=1:t*500;

a=fscanf(s,'%d');
v1(i)=a
i=i+1;
wait time
end
fclose(s);
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Dave
Val: 497
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

define delay time in a for cylce in matlab

Publicado por Dave (1094 intervenciones) el 09/04/2013 17:14:40
Hi Gabriel;

You should include the function "pause" in you For loop.

For example:

1
2
3
4
5
6
for ...
...
...
pause (0.1)
% This represents a 0.1-second pause.
end


On the other hand, I want to comment you on my Matlab programming services, If you know someone interested in my programming services, please Give her my personal information, and I will help in the development of your project or research.

I hope this is of some help.

regards

Dave Correa
[email protected]
Matlab Programming Services
http://fismatlab.blogspot.com/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar