Stress strain average unique sample points

15 views (last 30 days)
Hi,
For my master thesis i have done several tensile and flexural tests. I plotted most of these in matlab to find an average curve out of 5 test samples. For most of the materials this worked fine. Now i get an error that my sample points have to be unique. I manually import my data as collum vectors. So I have one collum vector for strain (STRAIN1-5), and 1 for stress (STDF1-5). How can i now make sure i only have unique values for strain and stress and still have the right values of strain and stress matching each other? I added my code below.
Thank you in advance!
figure
title('ONYX -45°/45°')
xlabel('Strain(%)')
ylabel('Stress (MPa)')
hold on
plot(STRAIN1,STDF1,'Color' ,[0, 0.4470, 0.7410])
hold on
plot(STRAIN2,STDF2,'Color' ,[0.9290, 0.6940, 0.1250])
hold on
plot(STRAIN3,STDF3,'Color' ,[0.4940, 0.1840, 0.5560])
hold on
plot(STRAIN4,STDF4,'Color' ,[0.4660, 0.6740, 0.1880])
hold on
plot(STRAIN5,STDF5,'r')
hold on
xlim([0 8])
ylim([0 100])
Xavg=[0:0.001:8];
Y1avg = interp1(STRAIN1,STDF1,Xavg);
Y2avg = interp1(STRAIN2,STDF2,Xavg);
Y3avg = interp1(STRAIN3,STDF3,Xavg);
Y4avg = interp1(STRAIN4,STDF4,Xavg);
Y5avg = interp1(STRAIN5,STDF5,Xavg);
Y1avg=Y1avg';
Y2avg=Y2avg';
Y3avg=Y3avg';
Y4avg=Y4avg';
Y5avg=Y5avg';
Yavg = mean([Y1avg Y2avg Y3avg Y4avg Y5avg],2);
plot(Xavg,Yavg,'-.k','LineWidth',2)
hold on

Accepted Answer

KSSV
KSSV on 22 May 2020
If (x,y) are your data points. Use the following to avoid the error.
[x,idx] = unique(x) ;
y = y(idx) ;
yi = interp1(x,y,xi) ;
  1 Comment
laurens willems
laurens willems on 22 May 2020
Thank you! i tried it before and it didn't work as i forgot the y(idx). Now it worked perfect thank you!!

Sign in to comment.

More Answers (0)

Categories

Find more on Stress and Strain in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!