26 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

Stephen Cobeldick
on 16 Feb 2017

Edited: Stephen Cobeldick
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

For newer MATLAB versions use the https://www.mathworks.com/help/matlab/ref/scatteredinterpolant-class.html.

Because the Excel file is very inconvenient to work with I transferred the data to simple CSV files, available here:

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

Start Hunting!
## 4 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429235

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429235

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429236

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429236

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429238

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429238

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429259

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/325331-interpolation-between-multi-curves#comment_429259

Sign in to comment.