Need a MATLAB code to plot the PE loop, calculate the stored and recovered energy. I am ready to pay for the code.
조회 수: 7 (최근 30일)
이전 댓글 표시
I measure the PE loop for antiferroelectric materials. Normally data has double PE loop (Please see the attached file). I need to calculate the area of the loop as shown in figure. All I want to do load the excel file in matlab and run the code to calculate the above parameters.
채택된 답변
Mathieu NOE
2021년 9월 28일
hello
you lucky guy... had some time to throw a few matlab lines ...
here you are my friend and without any financial penalty
I took the positive x data only, splitted in two subsets corresponding to the lower and upper segments. Then I resampled the experimental data to a common x axis for simpler and more accurate integration
I think the code is quite simple and the plots speak for themselves
have a good day
code :
clc
clearvars
Tab = readtable('PLZST-2-43-6-sample-1-180 micron-170kV-cm-uniform.xls',"NumHeaderLines",46) ;
Field = Tab.Field_kV_cm_;
Polarization = Tab.MeasuredPolarization__C_cm2_;
% make both segments have same x axis basis so integration is simpler and more accurate :
% the simple answer is to use trapz on the difference if the y-values : Area = trapz(x,y1-y2)
[Field_max_value,Field_max_index] = max(Field);
x_common = linspace(0,Field_max_value,300);
% first segment ("low")
x1 = Field(1:1:Field_max_index); % NB sorting in ascending order
y1 = Polarization(1:1:Field_max_index); % NB sorting in ascending order
% interpolate on common x axis
y1int = interp1(x1,y1,x_common,'spline','extrap');
% second segment ("high")
x2 = Field(2*Field_max_index:-1:Field_max_index); % NB sorting in ascending order
y2 = Polarization(2*Field_max_index:-1:Field_max_index); % NB sorting in ascending order
% interpolate both datas on common x axis
y2int = interp1(x2,y2,x_common,'spline','extrap');
% plot to show original data and interpolated data for both data segments
% zoom around x = 0 to see how the data is generated (extrapolation for x = 0)
figure(1)
plot(x1,y1,'b',x_common,y1int,'*r',x2,y2,'g',x_common,y2int,'*k');
xlabel('Field (kV/cm)');
ylabel('Polarization (C/cm²)');
legend('segment 1','segment 1 interpolated','segment 2','segment 2 interpolated');
% now let's compute the area
Area = trapz(x_common,y2int-y1int);
plots :
general plot (segmentation of the data)
zoom around zero
댓글 수: 5
Mathieu NOE
2021년 10월 12일
편집: Mathieu NOE
2021년 10월 12일
hello again
maybe this is because the new file is slightly different from the first one
for example check the number of header lines between the two files
for the first file , we skipped the first 46 lines as stated here :
Tab = readtable('PLZST-2-43-6-sample-1-180 micron-170kV-cm-uniform.xls',"NumHeaderLines",46) ;
also check if the variable names have changed :
Field = Tab.Field_kV_cm_;
Polarization = Tab.MeasuredPolarization__C_cm2_;
if you're still stucked, send me please your new data file
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!