필터 지우기
필터 지우기

Reading an Array Data from the Serial Port

조회 수: 6 (최근 30일)
Merve ozdas
Merve ozdas 2023년 7월 21일
답변: VBBV 2023년 7월 22일
How can I read the ARRAY data with 256 samples Array[256] from the Serial Port in matlab and show as a plot. I was using
s=serialport('COM13',19200);
i=1;
% out1 = instrfind('Port','COM3')
%open serial port
while(true)
data=readline(s);
deta(i)=str2double(data)
y=deta
drawnow;
% d = designfilt ('bandstopiir','FilterOrder',2,'HalfPowerFrequency1',46,'HalfPowerFrequency2',65,'SampleRate',1000); y = filter (d,deta);
if i<600
TF = isnan(deta)
deta(TF)=0;
end
h=[h;y(i)]
plot(y, 'r-');
i=i+1
end
But I am getting every values one by one, this makes my sampling rate really slow, normally I am using 13 kHz in MSP430, but I am taking 60 Hz sampling Rate. Can you help me? How can I Read and Plot an ARRAY with 256samples from the Serial Port. Thank you.

답변 (1개)

VBBV
VBBV 2023년 7월 22일
data=read(s);

Try using read function which has option to read how many data samples you want at a time. It also allows to read all data input at once, which is something you want.

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by