Stress strain average unique sample points

조회 수: 11 (최근 30일)
laurens willems
laurens willems 2020년 5월 22일
댓글: laurens willems 2020년 5월 22일
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

채택된 답변

KSSV
KSSV 2020년 5월 22일
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
laurens willems
laurens willems 2020년 5월 22일
Thank you! i tried it before and it didn't work as i forgot the y(idx). Now it worked perfect thank you!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by