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

4 visualizzazioni (ultimi 30 giorni)
Hi everybody.. I am having the following warning using polyval
It happens after I delete negative values from a dataset since before this cleaning it worked.
% TOLGO I VALORI NEGATIVI
% Creo un array di indici logici che indica quali righe hanno almeno un valore negativo
idx_neg = any(rawData < 0, 2);
cleanData = rawData;
% Elimino le righe selezionate
cleanData(idx_neg, :) = [];
pressureIN = cleanData(:,1);
pressureOUT= cleanData(:,2);
flowrate = cleanData(:,3);
PHeadLoss = pressureIN - pressureOUT;
%DATA
figure('Name',' PRESSURE HEAD LOSS vs FLOWRATE')
plot(flowrate, PHeadLoss, '*k');
title('Pressure Head Loss vs FLOW RATE');
xlabel('flow rate');
ylabel('P Head Loss');
hold on
%densityplot(flowrate, PHeadLoss, [50,50]);
[p, S, mu] = polyfit(flowrate, PHeadLoss, 2)
[y,delta] = polyval(p,flowrate,S,mu);
%LINEAR FIT
plot(flowrate, y, 'r-');
%hold on
% Linear Fit of Data with 95% Prediction Interval
%plot(flowrate,y+2*delta,'m--',flowrate,y-2*delta,'m--')
title('Pressure Head Loss vs FLOW RATE');
xlabel('flow rate');
ylabel('P Head Loss');
while the watning is:
p =
NaN NaN NaN
S =
struct with fields:
R: [3×3 double]
df: 751629
normr: NaN
mu =
NaN
NaN
Warning: Matrix is singular, close to singular or badly scaled.
Results may be inaccurate. RCOND = NaN.
> In polyval (line 109)
Thanks in advance!

Risposte (1)

Bruno Luong
Bruno Luong il 30 Gen 2024
Modificato: Bruno Luong il 30 Gen 2024
Check your data with this command
all(isfinite(rawData(:)))
if it returns 0/false then your data is not valid

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by