How can i read from CAN and save the messages in a timetable?

4 visualizaciones (últimos 30 días)
Hi... i'm trying to read messages from CAN and i have (maybe a simple) problem that i don't know how to fix.
The thing is... everything is ok about reading but about saving... well...
Let me explain with some code
start(rxCh); % i start a channel to receive
tic; % start a timmer
while (toc < samplingtime) % i want to reaad the CAN messages for a 'samplingtime'
for t=0:1:samplingtime*samplefreq %so if i want to read every 1s during 10 s (ex) i will read 10 times
rxMsg= receive(rxCh, Inf, 'OutputFormat', 'timetable'); % my problem is right here
pause(timebsamples); % i will wait a litle bit (in the case of the example it will be 1 sec)
toc %just to check the times
end
end
My problem is when i update the rxMsg i loose everything that i had there before.
can someone give me a help... i don't want to loose information ...
Thanks in advance

Respuesta aceptada

Peter Perkins
Peter Perkins el 19 de Dic. de 2017
Jose, I think typically you would want to vertically concatenate all the timetables you get. You might either do something like
rxMsg = [rxMsg; receive(...)];
or
rxMsg = cell(1,N);
for ...
...
rxMsg{t} = receive(...);
...
end
rxMsg = vertcat(rxMsg{:});
but it's hard to tell what you are really going for.

Más respuestas (0)

Categorías

Más información sobre Mathematics 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