How to generate new result points based on known model curve?

38 Ansichten (letzte 30 Tage)
Andrei
Andrei am 26 Okt. 2024 um 14:46
Kommentiert: John D'Errico am 26 Okt. 2024 um 21:38
Hi All,
i do have an existing curve built based on known x and y.
I want to use the model curve to generate new data points. considering:
x=[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
and y with lower and upper limits of:
y=[109.601, ... , 10.96007]
On model curve point 570 & 26.5 would correspond to 100 & 109.601 while point 138 & 385.1 to 10 & 10.96007
Existing curve based on:
x=[570, 565.2, 560.4, 555.6, 550.8, 546, 541.2, 536.4, 531.6, 526.8, 522, 517.2, 512.4, 507.6, 502.8, 498, 493.2, 488.4, 483.6, 478.8, 474, 469.2, 464.4, 459.6, 454.8, 450, 445.2, 440.4, 435.6, 430.8, 426, 421.2, 416.4, 411.6, 406.8, 402, 397.2, 392.4, 387.6, 382.8, 378, 373.2, 368.4, 363.6, 358.8, 354, 349.2, 344.4, 339.6, 334.8, 330, 325.2, 320.4, 315.6, 310.8, 306, 301.2, 296.4, 291.6, 286.8, 282, 277.2, 272.4, 267.6, 262.8, 258, 253.2, 248.4, 243.6, 238.8, 234, 229.2, 224.4, 219.6, 214.8, 210, 205.2, 200.4, 195.6, 190.8, 186, 181.2, 176.4, 171.6, 166.8, 162, 157.2, 152.4, 147.6, 142.8, 138]
y=[26.5, 36.5, 46.3, 55.9, 65.2, 74.3, 83.2, 91.8, 100.2, 108.4, 116.4, 124.2, 131.8, 139.2, 146.4, 153.5, 160.3, 167, 173.5, 179.9, 186.1, 192.1, 198, 203.7, 209.3, 214.8, 220.1, 225.3, 230.3, 235.2, 240, 244.7, 249.2, 253.7, 258, 262.2, 266.3, 270.3, 274.2, 278.1, 281.8, 285.4, 288.9, 292.4, 295.7, 299, 302.2, 305.3, 308.3, 311.2, 314.1, 316.9, 319.6, 322.3, 324.9, 327.4, 329.9, 332.3, 334.6, 336.9, 339.1, 341.3, 343.4, 345.5, 347.5, 349.4, 351.4, 353.2, 355, 356.8, 358.5, 360.2, 361.8, 363.4, 365, 366.5, 368, 369.4, 370.8, 372.2, 373.5, 374.8, 376.1, 377.3, 378.5, 379.7, 380.9, 382, 383.1, 384.1, 385.1]
Thank you.

Antworten (1)

dpb
dpb am 26 Okt. 2024 um 16:08
Bearbeitet: dpb am 26 Okt. 2024 um 18:14
x=[570, 565.2, 560.4, 555.6, 550.8, 546, 541.2, 536.4, 531.6, 526.8, 522, 517.2, 512.4, 507.6, 502.8, 498, 493.2, 488.4, 483.6, 478.8, 474, 469.2, 464.4, 459.6, 454.8, 450, 445.2, 440.4, 435.6, 430.8, 426, 421.2, 416.4, 411.6, 406.8, 402, 397.2, 392.4, 387.6, 382.8, 378, 373.2, 368.4, 363.6, 358.8, 354, 349.2, 344.4, 339.6, 334.8, 330, 325.2, 320.4, 315.6, 310.8, 306, 301.2, 296.4, 291.6, 286.8, 282, 277.2, 272.4, 267.6, 262.8, 258, 253.2, 248.4, 243.6, 238.8, 234, 229.2, 224.4, 219.6, 214.8, 210, 205.2, 200.4, 195.6, 190.8, 186, 181.2, 176.4, 171.6, 166.8, 162, 157.2, 152.4, 147.6, 142.8, 138];
y=[26.5, 36.5, 46.3, 55.9, 65.2, 74.3, 83.2, 91.8, 100.2, 108.4, 116.4, 124.2, 131.8, 139.2, 146.4, 153.5, 160.3, 167, 173.5, 179.9, 186.1, 192.1, 198, 203.7, 209.3, 214.8, 220.1, 225.3, 230.3, 235.2, 240, 244.7, 249.2, 253.7, 258, 262.2, 266.3, 270.3, 274.2, 278.1, 281.8, 285.4, 288.9, 292.4, 295.7, 299, 302.2, 305.3, 308.3, 311.2, 314.1, 316.9, 319.6, 322.3, 324.9, 327.4, 329.9, 332.3, 334.6, 336.9, 339.1, 341.3, 343.4, 345.5, 347.5, 349.4, 351.4, 353.2, 355, 356.8, 358.5, 360.2, 361.8, 363.4, 365, 366.5, 368, 369.4, 370.8, 372.2, 373.5, 374.8, 376.1, 377.3, 378.5, 379.7, 380.9, 382, 383.1, 384.1, 385.1];
hAx=subplot(2,1,1);
plot(x,y,'x')
xlabel('X'),ylabel('Y')
ix=find(x==138); % locate the two target points; find the second
[x(ix) y(ix)]
ans = 1×2
138.0000 385.1000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
hold on
ix=[1;ix]; % the first is by inspection; same idea as above if not
scatter(x(ix),y(ix),'r','filled') % show them on plot
% 570 & 26.5 would correspond to 100 & 109.601 while point 138 & 385.1 to 10 & 10.96007
X=[100;10]; % desired scaled X, Y end points
Y=[109.601;10.96007];
bx=polyfit(x(ix),X,1); % the linear mapping of x-->X range
by=polyfit(y(ix),Y,1); % and ditto for y-->Y
xs=polyval(bx,x); % new x at each previous
ys=polyval(by,y); % ditto y
hAx(2)=subplot(2,1,2);
plot(xs,ys,'*') % plot the rescaled results
xlabel('Xscaled'),ylabel('Yscaled')
xlim(polyval(bx,xlim(hAx(1)))), ylim([0 120]), grid on % set xlim to match unscaled to compare
You can fit the transformed data to some interpolating function or just interpolate with the new data arrays over the scaled range; your choice.
The "trick" is to just do a linear transformation from one scale to the other; with the two points one can calculate the two slopes and interecepts by hand, but in MATLB it's simpler to just use the builtin poly function twins...
  1 Kommentar
John D'Errico
John D'Errico am 26 Okt. 2024 um 21:38
This is how I would interpret the request. But it is just a wild guess.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Linear and Nonlinear Regression 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!

Translated by