Using tabular data for Curve fitting of function z = f (x, y) with incomplete values of z. These blank z (i, j) automatically takes zero values and this is a problem

3 Ansichten (letzte 30 Tage)
Dear Community Members,
I have tabular data for data selection in the Curve fitter in the form of:.
I have to use curve fitter for z = f (x, y), but I don't have values for z(2, 4), z(3,3) and z(3,4) (red one).
In the workspase variable (matrix Z) these blank places automatically take values, which is zeros. Is there any instrument to ignore these zeros and the regression analyses to be made only with the available z values. In other words to ignore the three zero values in the down right corner? May be something with the weights instrument? If I simply use the matrix with zero values, without any additional actions, of course the regression method uses these z(2, 4) = 0, z(3,3) = 0 and z(3,4) = 0 and the results are unacceptable.
  2 Kommentare
Torsten
Torsten am 23 Sep. 2024
Supply z as a vector instead of a matrix and don't list these three data points in the vector. What's the problem ?
Boyan
Boyan am 25 Sep. 2024
Hi, Torsten,
The data is shown in picture below. x(i) is in green, y(j) is in blue. Z values simply form a matix, I think that I can't supply them as a vector.
I have no problem to obtain formula coefficients, if there are values in the right down corner.
In fact there is second issue, but this is asked in another question. The second issue is that there is no problem with regression analyses if the formula is z = a*x^n/y^m, but have problem when adding the "b" in the denominator and the formula is z = a*x^n/(y+b)^m.
So, to return to the first issue – how to make the regression method just to ignore missing values in the right down corner instead thinking for them like zeros.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Torsten
Torsten am 25 Sep. 2024
Bearbeitet: Torsten am 25 Sep. 2024
green = [5 5 5 5 5 4 4 4 4 1 1 1];
blue = [5 10 15 20 25 5 10 15 20 5 10 15];
yellow = [455 322 261 205 169 410 306 246 191 257 185 151];
F = @(p) fun(p,green,blue,yellow);
p0 = [1 1 1 1];
p = lsqnonlin(F,p0);
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
F(p)
ans = 1×12
1.7303 9.7596 9.9255 -10.0906 -21.7707 -12.4649 14.9799 11.9889 -9.4727 -5.7667 3.9900 5.4487
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
norm(F(p))
ans = 38.2707
a = p(1)
a = 674.6751
n = p(2)
n = -0.5377
b = p(3)
b = -0.2283
m = -p(4)/2
m = -0.0748
function res = fun(p,green,blue,yellow)
a = p(1);
n = p(2);
b = p(3);
m = p(4);
res = yellow - a*blue.^n.*((green+b).^2).^m;
end

Weitere Antworten (1)

Cris LaPierre
Cris LaPierre am 25 Sep. 2024
I'd suggest using the standardizeMissing function to convert the 0 values to nan. The Curve Fitter app will ignore NANs.
  1 Kommentar
Boyan
Boyan am 29 Sep. 2024
Thank you, @Cris LaPierre,
Your advice also works (like "the vector approach" of @Torsten). I implemented it with small change. I have simply import (with "import data" tool) Excel table (the matrix) and the the blank cells became NaN. Already with NaN it works. Before I simply input the table data by hand and leave blank cells in the down right corner of the matrix and the cellc automatically have accepted value of 0.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by