# How to interpolate an intermediate curve from curves with different number of data points?

7 views (last 30 days)
Henry Eriksson on 8 Sep 2020
Commented: Henry Eriksson on 8 Sep 2020
Hello
See the attached picture. The picture shows 4 stress-strain curves, each curve is for a different temperature. What I want is to approximate a curve for 60 deg Celsius. How do I do this? I think there will be lots of problems stemming from that each curve stop at a different strain. I have looked at this question ( https://stackoverflow.com/questions/23494254/interpolation-between-two-curves-matlab?fbclid=IwAR1XKpmOxYtRmd1Zibe6zo4hNRNJAXI2NhC8ByFx-V4HmzQ2XiUl9GTn-Vg ) and answer but I dont think it will give me what I want.
##### 2 CommentsShowHide 1 older comment
Henry Eriksson on 8 Sep 2020
Thank you!
I attached the data. I will try what you said and hoping in the meantime that I get some help.

KSSV on 8 Sep 2020
t = data(:,1) ;
strain = data(:,2) ;
stress = data(:,3) ;
%
[c,ia,ib] = unique(t) ;
N = length(c) ;
x = cell(N,1) ;
y = cell(N,1) ;
z = cell(N,1) ;
for i = 1:N
x{i} = strain(ib==i) ;
y{i} = stress(ib==i) ;
z{i} = t(ib==i) ;
end
% Make all cells to same size and into a matrix
Y = zeros(N,100) ;
for i = 1:N
xi = x{i} ; yi = y{i} ;
xxi = linspace(x{end}(1),x{4}(end),100) ;
yyi = interp1(xi,yi,xxi) ;
yyi(isnan(yyi)) = yi(end) ;
Y(i,:) = yyi ;
end
X = repmat(xxi,4,1) ;
Z = repmat(c,1,100) ;
% use contour
contour(X,Y,Z)
colorbar
Henry Eriksson on 8 Sep 2020
Thank you! I have tested this out and it seems to do about what I want! :D I will understand it a bit more and comment it.