Azzera filtri
Azzera filtri

Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN

38 visualizzazioni (ultimi 30 giorni)
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')
  5 Commenti
dpb
dpb il 21 Lug 2024 alle 20:00
ADDENDUM:
In a first try on here I couldn't duplicate the error with test randomized data, even if passed identical columns so I dunno what's going on. I don't have whatever TB fuse you're using is from and debugging on this platform is nigh upon impossible so can't really tell from just where the issue may have arisen.
But see <Cleve's Condition Number> for all you could ever want to know about what it is and represents...
Mayhaps our resident math whiz @John D&#39;Errico will stumble over this and have more insight as to what is going on internally.
I'd suggest the above heuristics to just examine the traces, though, to see what they look like and, of course you can always run rcond on them yourself to see if can isolate which is the culprit.
dpb
dpb il 21 Lug 2024 alle 21:10
ADDENDUM SECOND:
Oh! Head slap! The other other possibility is as simple as
x=rand(5);
x(2,2)=nan;
rcond(x)
ans = NaN
If there's a NaN in one of the time traces, that'll do it if the input checking doesn't catch it out before passing the input on to the guts of the routine...
Need to do a
any(isnan(accelerometerReadings))
any(isnan(gyroscopeReadings))
If either returns true, you've found the culprit...

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Random Number Generation 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