2 views (last 30 days)

Show older comments

I have 2 sets of data.

First set is black , 6% measuring target that gives me certain stat error at given distance . Same goes for white, 90% measuring target.

2 sets of data have different length. I use polyfit and polyval to obtain the equations .

Ex:

y1 = 0.0001x^4 - 0.0022x^3 + 0.0312x^2 -0.1143x + 0.4783 for 6%

y2 = 0.0004x^2 -0.0024x +0.1762 for 90%

How can I obtain an equation for 20% measuring target ? I need to estimate/approximate a set of data for 20% based on my available data (6% and 90%). Is there any method to do this ?

My codes as below:

DistaveB=Data(3:15 , 2);

DistaveB=cell2mat(DistaveB);

DistaveW=Data(16:32 , 2);

DistaveW=cell2mat(DistaveW);

StatErrorB=Data(3:15 , 3);

StatErrorB=cell2mat(StatErrorB);

StatErrorW=Data(16:32 , 3);

StatErrorW=cell2mat(StatErrorW);

SignalaveB=Data(3:15 , 4);

SignalaveB=cell2mat(SignalaveB);

SignalaveW=Data(16:32, 4);

SignalaveW=cell2mat(SignalaveW);

CDistaveB=DistaveB./1000;

p = polyfit(CDistaveB, StatErrorB, 4);

f = polyval(p,CDistaveB);

figure(2)

plot(CDistaveB, StatErrorB , 'o')

hold on

plot(CDistaveB, f)

CDistaveW=DistaveW./1000;

pW = polyfit(CDistaveW, StatErrorW, 2);

fW = polyval(pW,CDistaveW);

plot(CDistaveW, StatErrorW , 'o')

plot(CDistaveW, fW)

Any suggestions will be helpful, Thank you!

ps: I do not have any additional toolbox to solve this.

William Rose
on 18 Aug 2021

See my quesitons in the ealrier comments.

I moved your data into a text file (attached) and made a few tweaks to your code (see attached code). It runs without error . It produces the plot below.

I understand from your original post that you want to find an equation to make predictions for the 20% case, based on the data you have for 6% and 90%. Here's how you can do it.

- Only do this over the Distance range where you have data for both 6% and 90%. Don't extraolate the 6% model to larger distances.
- Use the 6% and 90% polynomials to predict data at N(=30 should be enough) evenly spaced distances, within the range of overlapping distances.
- Interpolate to 20%, to get N predictions for 20%.
- Fit a 4th order polynomial to the 20% predictions.
- Plot the 20% poly to make sure it looks OK.

Why use a 4th order poly for 13 points, and a second order for 17 points? Did you use standard statistical methods to choose the polynomial order for each case?

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

Start Hunting!