Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Outputting gyroscope data to array

1 visualizzazione (ultimi 30 giorni)
Kimberly Savitsky
Kimberly Savitsky il 7 Apr 2017
Chiuso: MATLAB Answer Bot il 20 Ago 2021
I am trying to plot angles in the z-axis (angz) over time. I have a 1:10 sample rate, so I am able to send 10 samples at a time to an array. However, the code overwrites these 10 samples and sends only the last 10 anglez values to the array (p(n)).
I am trying to adjust the code so I can send all angz values to an array for data analysis.
while abs(angz) < 360
for n = 1:10
q = a.gyroRead('z') - dc_offsetz;
if abs(q) > threshold
dt = toc(timer);
angz = (angz + (q/32768)*sensitivityz*dt - gyro_driftz);
p(n) = angz;
end

Risposte (1)

Joseph Cheng
Joseph Cheng il 7 Apr 2017
Modificato: Joseph Cheng il 7 Apr 2017
you're overwriting it with the p(n) as n only goes from 1 to 10 again and again. you'll have to increment p(#) beyond n or multiple of #*(1:10)
collectnum = 0;
while abs(angz) < 360
for n = 1:10
q = a.gyroRead('z') - dc_offsetz;
if abs(q) > threshold
dt = toc(timer);
angz = (angz + (q/32768)*sensitivityz*dt - gyro_driftz);
p(collectnum*10+n) = angz; %so you're increasing the index for every 10 points collected
end %added these end lines to show where you'll need to put the increment of 10 line
end
collectnum=collectnum+1; %need this after the end in your for loop to increment the multiple of 10.
end

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by