warning in Polyval - Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
2 次查看(过去 30 天)
显示 更早的评论
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!
1 个评论
回答(1 个)
Bruno Luong
2024-1-30
编辑:Bruno Luong
2024-1-30
Check your data with this command
all(isfinite(rawData(:)))
if it returns 0/false then your data is not valid
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!