How to get a transfer function for 2D data (curve to curve)

Hello everyone,
I need to get a transfer function/method to convert the coordinates from the blue curve to the green one.
This function will be used later on to transfer other curves similar to the blue one. I would be happy to get suggestions on how to solve this with matlab; are there any ready to use functions? Thanks in advance!

7 Comments

How are these two lines defined? Are you given a set of points or equations?
A set of points ( which can be transformed to two functions as shown after the table)
green blue
X Y X Y
0 0 0 0
0.001059717 43.64751459 0.001920619 48.27387686
0.002119433 87.29502919 0.005976431 143.9883646
0.003968407 160.5288104 0.010032244 234.5643786
0.00581738 233.7625916 0.014088057 319.0853264
0.006983757 281.3694824 0.018143869 397.606759
0.008150135 328.9763733 0.022199682 469.9342477
0.009316512 376.5832641 0.026255495 537.8732022
0.011066079 447.914171 0.030311307 602.6179703
0.012815645 519.2450778 0.03436712 663.8630212
0.014644737 591.0605906 0.038422932 722.1083145
0.016473829 662.8761033 0.042478745 777.4927279
0.018402328 734.9240578 0.046534558 830.571772
0.020330827 806.9720124 0.05059037 880.5955074
0.02190146 860.4624888 0.054646183 925.7863001
0.023472094 913.9529651 0.056992192 950.0933637
green: y = 40000*x
blue: y = -120000*x^2+23500*x
It seems that these equations are incorrect. They give the following waveform
it works just fine if you use a small range for x ( sorry, i forgot to mention that the x values are in percent )
x = [0:0.001:0.05];
y = 40000*x;
plot(x, y)
hold on
y = -120000*x.^2+23500*x;
plot(x, y)
It's worth mentioning that the original data are points read from the given picture. I just used a simple approximation to get the aforementioned equations.
If there is no definite rule to plot these two curves, then how can we make a reliable mapping from one curve to another?
The rule is simply using the given points or the equations within the given range.

Sign in to comment.

 Accepted Answer

I found a very good soulution:
p_corr is the function used to convert the blue curve to the green one.
x = 0:0.0025:0.065;
y_green = 40000*x; % equation of first line
y_blue = -120000*x.^2+23500*x; % equation of second line
% getting reverse polynomials
p_green = polyfit(y_green,x,2);
p_blue = polyfit(y_blue,x,3);
% getting correlation polynomial
x1 =0:100:1200;
y_blue = polyval(p_blue,x1);
y_green = polyval(p_green,x1);
p_corr = polyfit(y_blue,y_green,3); %correlation polynomial used to convert blur curve x values
y_corr= polyval(p_corr,y_blue);
figure
hold on
plot(y_green,x1)
plot(y_blue,x1)
plot(x_corr,x1,'o')
hold off

More Answers (1)

If you know the equation of both lines, you can use fsolve to map x-values from one curve to the other curve
y1 = @(x) 40000*x; % equation of first line
y2 = @(x) -120000*x.^2+23500*x; % equation of second line
x2 = 0:0.01:0.1; % x-values for point on y2
x1 = zeros(size(x2)); % x-values for point on y1 corresponding to x-values on y2
for i=1:numel(x1)
x1(i) = fsolve(@(x) y1(x) - y2(x2(i)), 0);
end
x = linspace(0,0.1,100);
figure;
hold on;
plot(x, y1(x));
plot(x, y2(x));
plot(x1, y1(x1), '+');
plot(x2, y2(x2), '+');
plot([x1; x2], [y1(x1); y2(x2)], '--')

Categories

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!