# Convert Data from array

3 visualizzazioni (ultimi 30 giorni)
David Jones il 22 Set 2020
Commentato: Star Strider il 24 Set 2020
Hi
I have attached a Jpeg of my data file displayed in a plot,(0 to 80mS) it shows exactly the data I need how do I convert this data to a new array as is in the plot. The actual array use to create the plot has 16000 samples at 5uS per sample which is of no interest .I just need the 1s and 0s as the plot along with there timing and not 16000 1s and 0s
Thank you for any help
David
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Star Strider il 22 Set 2020
I am not certain what your data are, or what you want to do.
One option for reducing the size of the array and still getting the plot is to use the find function to detect the 1 and 0 levels, and simply store them. Use the stem function to plot them. Another (likely more robust) option is to use the Signal Processing Toolbox midcross function to detect the pulses.
The find function might return something like this:
idx = [1 5 6 9 21 23 30 35 40];
that you could then plot as:
figure
stem(idx, ones(size(idx)), 'Marker','none')
grid
.
##### 8 CommentiMostra 6 commenti meno recentiNascondi 6 commenti meno recenti
David Jones il 24 Set 2020
Hi
I think I have managed to convert the data and have attached a copy of the decoded file can you please show me how I can extract the bits as in the file (Kpnai.jpg) start bits 8,9 and then the bytes, any help would be greatly appreciated.
Thank You
Star Strider il 24 Set 2020
I honestly have no idea how best to do that.
Try this:
y = D.manchesterDecoded;
st = [1 strfind(y, [0 1])];
en = strfind(y, [1 0]);
sten = sort([st en]);
dsten = diff([0 sten]); % <— This May Be What You Want
bitlen = min(dsten);
figure
histogram(dsten, 2*numel(st))
figure
plot(y, 'LineWidth',1.5)
grid
figure
plot(dsten)
grid
.

Accedi per commentare.

### Più risposte (1)

Ameer Hamza il 22 Set 2020
It seems that you want to reduce the number of samples. For your data, a good option seems to be decimate(): https://www.mathworks.com/help/signal/ref/decimate.html
##### 5 CommentiMostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Ameer Hamza il 22 Set 2020
Check this code. It just keeps one value of 1s and 0s for each consecutive sequence along with the corresponding time
n = numel(sqwvx);
Ts = 5e-6;
t = 0:Ts:(n-1)*Ts;
idx = find(diff(sqwvx));
t_new = t(idx);
sqwvx_new = sqwvx(idx);
David Jones il 23 Set 2020

Accedi per commentare.

### Categorie

Scopri di più su Multirate Signal Processing in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by