Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN
These data are already preprocessed so they are already syncronized and they are of the same size. However, when I tried running, MATLAB says: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. What seems to be the problem with this and how can this be fixed?
% load data
clear;
clc;
ld1 = load(‘CALT23A.mat’);
ld2 = load(‘CALT23D.mat’);
ld3 = load(‘CALT23M.mat’);
ld4 = load(‘CALT23S.mat’);
ld5 = load(‘CALT23K.mat’);
%%
% Accelerometer
accx = mean([ld1.Acceleration.X ld2.Acceleration.X ld3.Acceleration.X ld4.Acceleration.X],2,’omitnan’);
accy = mean([ld1.Acceleration.Y ld2.Acceleration.Y ld3.Acceleration.Y ld4.Acceleration.Y],2,’omitnan’);
accz = mean([ld1.Acceleration.Z ld2.Acceleration.Z ld3.Acceleration.Z ld4.Acceleration.Z],2,’omitnan’);
accelerometerReadings = [accx accy accz];
% Gyroscope
angx = mean([ld1.AngularVelocity.X ld2.AngularVelocity.X ld3.AngularVelocity.X ld5.AngularVelocity.X],2,’omitnan’);
angy = mean([ld1.AngularVelocity.Y ld2.AngularVelocity.Y ld3.AngularVelocity.Y ld5.AngularVelocity.Y],2,’omitnan’);
angz = mean([ld1.AngularVelocity.Z ld2.AngularVelocity.Z ld3.AngularVelocity.Z ld5.AngularVelocity.Z],2,’omitnan’);
gyroscopeReadings = [angx angy angz];
% Magnetometer
magx = mean([ld1.MagneticField.X ld2.MagneticField.X ld3.MagneticField.X ld4.MagneticField.X],2,’omitnan’);
magy = mean([ld1.MagneticField.Y ld2.MagneticField.Y ld3.MagneticField.Y ld4.MagneticField.Y],2,’omitnan’);
magz = mean([ld1.MagneticField.Z ld2.MagneticField.Z ld3.MagneticField.Z ld4.MagneticField.Z],2,’omitnan’);
magnetometerReadings = [magx magy magz];
%GPS
lat = mean([ld1.Position.latitude ld2.Position.latitude ld3.Position.latitude ld4.Position.latitude],2,’omitnan’);
long = mean([ld1.Position.longitude ld2.Position.longitude ld3.Position.longitude ld4.Position.longitude],2,’omitnan’);
speed = mean([ld1.Position.speed ld2.Position.speed ld3.Position.speed ld4.Position.speed],2,’omitnan’);
gps_speed_combined = speed;
%% IMU Filter (indirect Kalman Filter)
fuse = imufilter(‘SampleRate’,100, ‘DecimationFactor’,1,’AccelerometerNoise’,0.5,’GyroscopeNoise’,0.01);
q1 = fuse(accelerometerReadings, gyroscopeReadings);
orient1 = eulerd(q1, ‘ZYX’,’frame’);
f = figure;
f.Position(1:4) = [100 20 1100 600];
plot(orient1(:,3)); hold off
grid on
axis tight
xlabel(‘Time (sec)’);
ylabel(‘Angle (deg)’);
title(‘Orientation Estimate using IMU Filter’)
saveas(gcf, ‘imufilter.png’)These data are already preprocessed so they are already syncronized and they are of the same size. However, when I tried running, MATLAB says: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. What seems to be the problem with this and how can this be fixed?
% load data
clear;
clc;
ld1 = load(‘CALT23A.mat’);
ld2 = load(‘CALT23D.mat’);
ld3 = load(‘CALT23M.mat’);
ld4 = load(‘CALT23S.mat’);
ld5 = load(‘CALT23K.mat’);
%%
% Accelerometer
accx = mean([ld1.Acceleration.X ld2.Acceleration.X ld3.Acceleration.X ld4.Acceleration.X],2,’omitnan’);
accy = mean([ld1.Acceleration.Y ld2.Acceleration.Y ld3.Acceleration.Y ld4.Acceleration.Y],2,’omitnan’);
accz = mean([ld1.Acceleration.Z ld2.Acceleration.Z ld3.Acceleration.Z ld4.Acceleration.Z],2,’omitnan’);
accelerometerReadings = [accx accy accz];
% Gyroscope
angx = mean([ld1.AngularVelocity.X ld2.AngularVelocity.X ld3.AngularVelocity.X ld5.AngularVelocity.X],2,’omitnan’);
angy = mean([ld1.AngularVelocity.Y ld2.AngularVelocity.Y ld3.AngularVelocity.Y ld5.AngularVelocity.Y],2,’omitnan’);
angz = mean([ld1.AngularVelocity.Z ld2.AngularVelocity.Z ld3.AngularVelocity.Z ld5.AngularVelocity.Z],2,’omitnan’);
gyroscopeReadings = [angx angy angz];
% Magnetometer
magx = mean([ld1.MagneticField.X ld2.MagneticField.X ld3.MagneticField.X ld4.MagneticField.X],2,’omitnan’);
magy = mean([ld1.MagneticField.Y ld2.MagneticField.Y ld3.MagneticField.Y ld4.MagneticField.Y],2,’omitnan’);
magz = mean([ld1.MagneticField.Z ld2.MagneticField.Z ld3.MagneticField.Z ld4.MagneticField.Z],2,’omitnan’);
magnetometerReadings = [magx magy magz];
%GPS
lat = mean([ld1.Position.latitude ld2.Position.latitude ld3.Position.latitude ld4.Position.latitude],2,’omitnan’);
long = mean([ld1.Position.longitude ld2.Position.longitude ld3.Position.longitude ld4.Position.longitude],2,’omitnan’);
speed = mean([ld1.Position.speed ld2.Position.speed ld3.Position.speed ld4.Position.speed],2,’omitnan’);
gps_speed_combined = speed;
%% IMU Filter (indirect Kalman Filter)
fuse = imufilter(‘SampleRate’,100, ‘DecimationFactor’,1,’AccelerometerNoise’,0.5,’GyroscopeNoise’,0.01);
q1 = fuse(accelerometerReadings, gyroscopeReadings);
orient1 = eulerd(q1, ‘ZYX’,’frame’);
f = figure;
f.Position(1:4) = [100 20 1100 600];
plot(orient1(:,3)); hold off
grid on
axis tight
xlabel(‘Time (sec)’);
ylabel(‘Angle (deg)’);
title(‘Orientation Estimate using IMU Filter’)
saveas(gcf, ‘imufilter.png’) These data are already preprocessed so they are already syncronized and they are of the same size. However, when I tried running, MATLAB says: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. What seems to be the problem with this and how can this be fixed?
% load data
clear;
clc;
ld1 = load(‘CALT23A.mat’);
ld2 = load(‘CALT23D.mat’);
ld3 = load(‘CALT23M.mat’);
ld4 = load(‘CALT23S.mat’);
ld5 = load(‘CALT23K.mat’);
%%
% Accelerometer
accx = mean([ld1.Acceleration.X ld2.Acceleration.X ld3.Acceleration.X ld4.Acceleration.X],2,’omitnan’);
accy = mean([ld1.Acceleration.Y ld2.Acceleration.Y ld3.Acceleration.Y ld4.Acceleration.Y],2,’omitnan’);
accz = mean([ld1.Acceleration.Z ld2.Acceleration.Z ld3.Acceleration.Z ld4.Acceleration.Z],2,’omitnan’);
accelerometerReadings = [accx accy accz];
% Gyroscope
angx = mean([ld1.AngularVelocity.X ld2.AngularVelocity.X ld3.AngularVelocity.X ld5.AngularVelocity.X],2,’omitnan’);
angy = mean([ld1.AngularVelocity.Y ld2.AngularVelocity.Y ld3.AngularVelocity.Y ld5.AngularVelocity.Y],2,’omitnan’);
angz = mean([ld1.AngularVelocity.Z ld2.AngularVelocity.Z ld3.AngularVelocity.Z ld5.AngularVelocity.Z],2,’omitnan’);
gyroscopeReadings = [angx angy angz];
% Magnetometer
magx = mean([ld1.MagneticField.X ld2.MagneticField.X ld3.MagneticField.X ld4.MagneticField.X],2,’omitnan’);
magy = mean([ld1.MagneticField.Y ld2.MagneticField.Y ld3.MagneticField.Y ld4.MagneticField.Y],2,’omitnan’);
magz = mean([ld1.MagneticField.Z ld2.MagneticField.Z ld3.MagneticField.Z ld4.MagneticField.Z],2,’omitnan’);
magnetometerReadings = [magx magy magz];
%GPS
lat = mean([ld1.Position.latitude ld2.Position.latitude ld3.Position.latitude ld4.Position.latitude],2,’omitnan’);
long = mean([ld1.Position.longitude ld2.Position.longitude ld3.Position.longitude ld4.Position.longitude],2,’omitnan’);
speed = mean([ld1.Position.speed ld2.Position.speed ld3.Position.speed ld4.Position.speed],2,’omitnan’);
gps_speed_combined = speed;
%% IMU Filter (indirect Kalman Filter)
fuse = imufilter(‘SampleRate’,100, ‘DecimationFactor’,1,’AccelerometerNoise’,0.5,’GyroscopeNoise’,0.01);
q1 = fuse(accelerometerReadings, gyroscopeReadings);
orient1 = eulerd(q1, ‘ZYX’,’frame’);
f = figure;
f.Position(1:4) = [100 20 1100 600];
plot(orient1(:,3)); hold off
grid on
axis tight
xlabel(‘Time (sec)’);
ylabel(‘Angle (deg)’);
title(‘Orientation Estimate using IMU Filter’)
saveas(gcf, ‘imufilter.png’) matrix, singular MATLAB Answers — New Questions