Index in position 2 exceeds array?

1 Ansicht (letzte 30 Tage)
Ryan Leonard
Ryan Leonard am 16 Mär. 2018
Kommentiert: dpb am 18 Mär. 2018
My code starts at connector on:
connector on MDTP1
m = mobiledev;
m.AngularVelocitySensorEnabled = 1;
m.AccelerationSensorEnabled = 1;
m.Logging = 1;
for K = 1 : 5; pause(1); end
m.Logging = 0;
[av, tav] = angvellog(m);
[o, to] = orientlog(m);
yAngVel = av(:,2);
roll = o(:, 3);
plot(tav, yAngVel, to, roll);
legend('Y Angular Velocity', 'Roll');
xlabel('Relative time (s)');
tInit = datetime(m.InitialTimestamp, 'InputFormat', 'dd-MM-yyyy HH:mm:ss.SSS');
tAngVel = tInit + seconds(tav);
tOrient = tInit + seconds(to);
yAngVelDeg = yAngVel * 180/pi;
plot(tAngVel, yAngVelDeg, tOrient, roll);
legend('Y Angular Velocity', 'Roll');
xlabel('Absolute time (s)');
m.AngularVelocitySensorEnabled = 0;
clear m;
So I made this program, and it runs on my Android phone. It's supposed to collect data from the sensors available in the mobile MATLAB app and graph it. I ran the program once, and it worked. But now this error pops up when I run the code:
index in position 2 exceeds array bounds.
What does this mean and how would I fix it?
  5 Kommentare
Greg
Greg am 18 Mär. 2018
A lot of objects ( tcpip, udp, timer) don't die with clear, just the variable from the workspace. This might be true of mobiledev objects. Try:
delete('m');
clear('m');
On top of what dpb recommends.
dpb
dpb am 18 Mär. 2018
Good point Greg, I think there should be automagic destructors called so one isn't left with zombies...

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Greg
Greg am 18 Mär. 2018
Bearbeitet: Greg am 18 Mär. 2018
Adjust your code to:
connector off
clear m

Kategorien

Mehr zu Sensor Data Collection finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by