フィルターのクリア

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 Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by