Interpolation between multi curves

19 views (last 30 days)
clc clear close all x=linspace(0,180,180)*pi/180
y200 = -0.0023.*x.^6 + 0.0296.*x.^5 - 0.1574.*x.^4 + 0.3502.*x.^3 - 0.1597.*x.^2 + 0.0567.*x - 0.0009;% 200 km y500 = -0.0019.*x.^6 + 0.0219.*x.^5 - 0.1172.*x.^4 + 0.2772.*x.^3 - 0.1297.*x.^2 + 0.0306.*x + 0.0001;% 500 km y1000 = -0.0029.*x.^6 + 0.0342.*x.^5 - 0.1786.*x.^4 + 0.4265.*x.^3 - 0.3061.*x.^2 + 0.0695.*x - 0.0033; % 1000 km
figure(1) plot(x,y1000,x,y500,x,y200)
I want to use the interpolation method to find the curves at any required altitude in the plot below, I already have the the polynomial of each curve as seen in the script
  4 Comments
Stephen23
Stephen23 on 16 Feb 2017
"what I want is to find a new curves for any altitude I want such as 300 or 4500 km"
My answer will give you exactly that.
Stephen23
Stephen23 on 16 Feb 2017
Edited: Stephen23 on 16 Feb 2017
@Oday Shahadh: you just edited your question into something totally different. This does not help because your original task (interpolating scattered data) was much simpler than this one.
Your idea of creating polynomials and then trying to interpolate them is more difficult than simply using an interpolant on your original data. Basically to interpolate the polynomials you would have to generate some data points... then you might as well use the original data points. So what you are trying to do is more complicated.
If you want more help I would suggest that you:
  1. revert back to your original question, with the original figure.
  2. upload sample data (this is the third time that you have been asked to provide sample data).

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 16 Feb 2017
Edited: Stephen23 on 16 Feb 2017
Use one of the interpolation tools for scattered data:
If you edit your question and upload some sample data by clicking the paperclip button then I can show you how to do it. It is hard to demonstrate code using imaginary data.
EDIT the original question asked how to interpolate values that were obtained by digitising the curves in this figure:
EDIT based on the original question, this code will interpolate the data points directly:
% Read CSV files:
S = dir('*.csv');
C = cell(size(S));
A = nan(size(S));
for k = 1:numel(S)
C{k} = csvread(S(k).name,1,0);
A(k) = sscanf(S(k).name,'%d');
end
% Merge data into matrices:
N = cellfun('size',C,1);
A = arrayfun(@(a,n)repmat(a,n,1),A,N,'Uni',0);
M = [vertcat(A{:}),vertcat(C{:})]; % [alt,phi,F_e]
% Interpolate:
F = TriScatteredInterp(M(:,1:2),M(:,3),'natural');
and tested:
>> rho = 0:0.1:pi; % angles rho
>> alt = 800*ones(size(rho)); % altitude
>> out = F(alt,rho)
out =
Columns 1 through 7
NaN 0.024935 0.04987 0.074805 0.09974 0.12468 0.14961
Columns 8 through 14
0.17455 0.19948 0.22442 0.24935 0.27429 0.29923 0.32416
Columns 15 through 21
0.3491 0.37404 0.39897 0.42391 0.44885 0.47378 0.49872
Columns 22 through 28
0.52366 0.54859 0.57353 0.59847 0.62341 0.64835 0.67328
Columns 29 through 32
0.69822 0.72316 0.7481 0.77304
Because the Excel file is very inconvenient to work with I transferred the data to simple CSV files, available here:
  8 Comments
Oday Shahadh
Oday Shahadh on 17 Feb 2017
Can I ask for a clarification Stephen?
Stephen23
Stephen23 on 18 Feb 2017
@Oday Shahadh: of course. What would you like to ask about?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!