an average curve for multiple curves (with different lenghts)
29 views (last 30 days)
Show older comments
Hey,
I have 4 samples (with displacement [mm] and Force[KN]), every vector (sample) has a different lenght.
I'v plotted 4 curves for the samples, now I need to get a tTrendline ("Trendcurve") which presents the average of all samples and getting the values of it. AND that's all without excluding any of the vector values.
I could only get the average of the 4 curves depending on limitting the lenght of the 4 vectors, which may prevent me covering important field of the results.
Does anyone have an idea how should i do it?
thanks in advance.
Preparing the samples
%Sample 1
Weg1=WA1(:,1)
Last1=LastInstron1(:,1)
%Sample 2
Weg2=WA2(:,1)
Last2=LastInstron2(:,1)
%Sample 3
Weg3=WA3(:,1)
Last3=LastInstron3(:,1)
%Sample 4
Weg4=WA4(:,1)
Last4=LastInstron4(:,1)
plotting the 4 samples
grid on
plot(Weg1,Last1,'k-')
xlim([-0.0 7.5])
ylim([0 12.5])
hold on
plot(Weg2,Last2,'r-')
hold on
plot(Weg3,Last3,'b-')
hold on
plot(Weg4,Last4,'g-')
hold on
grid on
hold off
legend({'Sample 1','Sample 2','Sample 3','Sample 4'},'Location','southeast')
xlabel('Displacement [mm]','FontSize',12,'FontWeight','bold','Color','k')
ylabel('Force [KN]','FontSize',12,'FontWeight','bold','Color','k')
Arbeitslinie
% limitting the 4 vectors to get the average of them
tW1=Weg1(1:18211,1)
tW2=Weg2(1:18211,1)
tW3=Weg3(1:18211,1)
tW4=Weg4(1:18211,1)
tL1=Last1(1:18211,1)
tL2=Last2(1:18211,1)
tL3=Last3(1:18211,1)
tL4=Last4(1:18211,1)
avgDisp=(tW1+tW2+tW3+tW4)/4
avgForc=(tL1+tL2+tL3+tL4)/4
%plotting the average curve
plot(avgDisp,avgForc)
ylim([0 12])
xlabel('Displacement [mm]')
ylabel('Force KN')
% getting the values of the average
Arbeitslinie=[avgDisp avgForc]
0 Comments
Answers (1)
KSSV
on 30 Jun 2021
You do the interpolation and get all the curves to the same size. Read about interp1.
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!