How to create a hysteresis loop

113 views (last 30 days)
Alethia on 2 Jan 2023
Commented: Alethia on 3 Jan 2023
I am very new to coding and I want to understand how to generate a hysteresis loop for blood vessels. This work was done in mice but the ones I see on MatLab answer primarily have to do with magnetism and I am unsure how to tailor my data to fit the different equations/codes.
Below is the code I wrote which essentially plots my data set but it does not generate a loop per se.
lumenWT = (Old.WT_2283)
Unable to resolve the name 'Old.WT_2283'.
pressureWT = (Old.Pressure);
x = floor(length(lumenWT)/2);
x1 = lumenWT(1:x);
x2 = lumenWT(x:end);
y1 = pressureWT(1:x);
y2 = pressureWT(x:end);
L1 = plot(y1,x1,'-k',LineWidth=2);
hold on
L2 = plot(y2,x2,'-k',LineWidth=2);
legend([L1 L2 L3 L4], ...
'WT Loading','WT Unloading','Location','southeast');
ylabel('Lumen diameter (microns)')
grid on
An answer from a few years ago generate this script which is what I am hoping to recreate but I have not been successful. :
X = [-3:.2:3 3:-.2:-3];
Y = [tanh(X(1:length(X)/2)-1) tanh(X(length(X)/2+1:end)+1)];
patch(X,Y,[.5 1 .5]); hold on
I am kindly asking for some suggestions or some direction
Alethia on 3 Jan 2023
Thanks for taking the time to find and share this information with me. I have calculated the stress-strain curves in the past. Still, the challenge is that the outer diameter of the vessel, which is needed to calculate the wall thickness, is not always accurately recorded since these blood vessels are isolated from tissue. Pieces of tissue on the vessel tend to obscure the outer diameter recording. As such, I have opted to exclude that information, so I do not misrepresent the data. Currently, I am focusing solely on the internal diameter measurements I have been able to measure at the different pressures adequately. I was under the impression that the pressure-diameter relationship would be able to generate some derived hysteresis loop rather than the loading and unloading pressure diameter relationships.

Sign in to comment.

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 3 Jan 2023
Edited: Sulaymon Eshkabilov on 3 Jan 2023
Old = readtable('Old.xlsx');
lumenWT = (Old.WT_2283) ;
pressureWT = (Old.Pressure);
x = floor(length(lumenWT)/2);
x1 = lumenWT(1:x);
x2 = lumenWT(x:end);
y1 = pressureWT(1:x);
y2 = pressureWT(x:end);
x2 = rmmissing(x2);
y2 = rmmissing(y2);
L1 = plot(y1,x1,'-k','LineWidth', 2);
hold on
L2 = plot(y2,x2,'-k','LineWidth',2);
legend([L1 L2], ...
'WT Loading','WT Unloading','Location','southeast');
ylabel('Lumen diameter (microns)')
grid on
X = [x1; x2; -1*x1; -1*x2];
Y= [y1; y2; -1*y1; -1*y2];
patch(Y,X,[.5 1 .5]); hold on
  1 Comment
Alethia on 3 Jan 2023
This was helpful to incorporate the script from the previous answer so thank you very much for that. However, it is not quite what I am looking for. This script seems to be plotting the pressure-diameter relationship, but I think the hysteresis loop may be a derived loop from those values.

Sign in to comment.

William Rose
William Rose on 3 Jan 2023
[I moved my code to the "Answer" section, which is where I should have posted it initially.]
I relaize that you have raised and then lowered the pressure inside a blood vessel. YOu have measured the diameter as a funciton of pressure. You did the experiment in three specimens.
There is one rows on NaNs in the data, which we will remove.
Here is code to plot the pressure-diameter loops.
pres=data(:,1); %column 1 = pressure
diam=data(:,2:end); %columns 2-4=diameter
pres=pres(~isnan(pres)); %remove rows with NaN
diam=diam(~isnan(diam)); %remove rows with NaN
diam=reshape(diam,[],cols); %reshape diam to have 3 columns
rm=rows/2; %middle row number
plot(pres(1:rm),diam(1:rm,1),'-r','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,1),'--r','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,2),'-g','linewidth',2); hold on
plot(pres(rm+1:end),diam(rm+1:end,2),'--g','linewidth',2); hold on
plot(pres(1:rm),diam(1:rm,3),'-b','linewidth',2); hold on
xlabel('Pressure (mmHg'); ylabel('Diameter (\mum)');
grid on; title('Pressure versus Diameter')
legend('WT2272 up','WT2272 down','WT2283 up','WT2283 down',...
'WT2271 up','WT2271 down','location','southeast');
Good luck.


Find more on Stress and Strain 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!

Translated by