Borrar filtros
Borrar filtros

i am trying to get data from a sensor for a specific time i want to get data n a matrix which updates automatically can anyone help in creating a dynamic matrix

1 visualización (últimos 30 días)
clc; close all; clear all;
delete(instrfindall);
data=zeros(2000,1)
s = serial ( 'COM3', 'BaudRate', 115200);
fopen(s);
time = clock;
beginTime = time(1, 5);
endTime = beginTime;
while (endTime - beginTime) <= 0 % time elapse
data = fread(s)
time = clock;
endTime = time(1, 5);
end
i want data to update automatically
  4 comentarios
avinash pabbireddy
avinash pabbireddy el 19 de Oct. de 2013
i'm able to get the data but only 512*1 matrix and the matrix is updating automatically but the thing is i want the previous values also
dpb
dpb el 19 de Oct. de 2013
No klew what xbee is, sorry...have to assume whoever is at Answers while they know Matlab they may be is as or even more ignorant of your situation as you may be on Matlab... :)
I presume at a guess perhaps you've initialized data as zeros(512,1) or somesuch is why it "works" as it does?
Would seem you would, then, to save additional data need to have another larger buffer or write to disk or just create as large a buffer as you want, maybe???

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Mzo. de 2014
You are overwriting the "data" variable each time through your "while" loop. Either add the incoming data to the end of "data" or else take the just-read "data" and add it to the end of some other variable. Using a cell array might make sense.
Be sure to read the documentation about the conditions under which an fread() is considered to be satisfied. With the configuration you have given, fread() is going to keep going until the device gives an error or until the default buffer is filled up (however big that is.)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by