get the linear fitting for all the possible X and Y combination
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have the X data [30 60 80 100]
for the first X value (the 30) it could corresponds to four Y values 0.1 0.2 0.3 0.4
for the second X value (the 60) it also corresponds to four Y values 0.5 1.0 1.5 2.0
for the third X value (the 80) it also corresponds to four Y values 1.5 2.0 2.5 3.0
for the fourth X value (the 100) it also corresponds to four Y values 2.5 3.0 3.5 4.0
That is to say, I have 4*4*4*4=256 possible combinations of (X,Y), and thus 256 possible slopes.
So far, I only know that the linear fitting can be obtained by using the code: polyfit(x,y,1) Can anyone please tell me how to get all the 256 possible slopes?
thanks
0 Kommentare
Antworten (1)
Image Analyst
am 27 Jul. 2014
Not sure how you get 256. You have 4 X, and for each X you have only 4 Y, so that's 16 slopes. The first X only uses those Y and not any of the other Y is what you said. Similar for the other X - they use only 4 particular Y, not all the Ys.
How about this:
X = [30 60 80 100]
Y = [...
0.1 0.2 0.3 0.4;
0.5 1.0 1.5 2.0;
1.5 2.0 2.5 3.0
2.5 3.0 3.5 4.0]
for col = 1 : length(X)
for row = 1 : size(Y, 1)
slope(row, col) = Y(row, col) / X(col);
end
end
% Print 16 slopes to command window:
slope
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!