get the linear fitting for all the possible X and Y combination
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Image Analyst
2014년 7월 27일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!