Need a MATLAB code to plot the PE loop, calculate the stored and recovered energy. I am ready to pay for the code.

5 views (last 30 days)
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.
  1 Comment
Rik
Rik on 28 Sep 2021
Have a read here and here. It will greatly improve your chances of getting an answer.
If you want to hire someone to write the code for you, you can contact the Mathworks consultancy service. (or anyone else who offers such services)

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 28 Sep 2021
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 Comments
Anand Gaur
Anand Gaur on 11 Oct 2021
How did you import the file. I am trying to run the script woth other data set ut seem like it not working. Also I am totally new to Matlab.
Mathieu NOE
Mathieu NOE on 12 Oct 2021
Edited: Mathieu NOE on 12 Oct 2021
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!