How do I obtain binary (in 0's and 1's) data from the serial port?
Mostra commenti meno recenti
I want to plot the bit data signal from the serial port. I use the command fread as Matlab say that fread is the funtion to read binary data. But when I use fread, I got numbers like 10,41,83,etc instead of 0 and 1. I want to view the signal as 0 and 1 so the plot is like squarewave. What am I supposed to do?
Here is my code:
x=0:0.01:10;
y=fread(s);
cla;drawnow;
h=plot(handles.axes1,x(1),y(1));grid on; hold on; legend data;
for idx = 1 : length(x);
set(h,'xdata',x(1:idx),'ydata',y(1:idx));drawnow; end;
% s is the serial.
2 Commenti
Ashish Uthama
il 11 Lug 2011
how about using dec2bin to convert to binary?
Adi Mico
il 12 Lug 2011
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Pulsed Waveforms in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!