You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
I would like to write a for loop to calculate fwhm value based on a range of Strain values. Say Strain = 50:10:150 and find the corresponding fwhm values in a vector
2 views (last 30 days)
Show older comments
X = (0:0.01:0.3);
Y = -9200*(X).^2 + 2760*X;
%Plot Graph
% Create figure
figure1 = figure('Color',[1 1 1]);
% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create scatter
plot(X,Y,'DisplayName','Voltage');
% Create ylabel
ylabel('Strain');
xlabel('Time')
% Find the Given threshold Strain
Strain = 30;
hold on;
yline(Strain, 'Color', 'r', 'LineWidth', 1);
%Find elements where y is above the thresholdHeight
aboveThreshold = Y > Strain;
smallFontSize = 8;
% Label each group.
[groups, numRegions] = bwlabel(aboveThreshold);
fwhm=zeros(1,length(numRegions))';
x1val=zeros(1,length(numRegions))';
x2val=zeros(1,length(numRegions))';
%loop
for r = 1 : numRegions
% Get a mask for this particular group
mask = groups == r;
% Logical "map" of where this group is.
indexes = find(mask);
% Get actual element (index) numbers.
% Find left edge
index1 = min(indexes);
x1 = X(index1);
% Find right edge
index2 = max(indexes);
x2 = X(index2);
x1val(r)=x1;
x2val(r)=x2;
% Compute the full width, half max.
fwhm(r) = x2 - x1;
end
Accepted Answer
Star Strider
on 7 Jun 2022
Calculating the width for every value of ‘Strain’ is reasonably straightforward —
X = (0:0.01:0.3);
Y = -9200*(X).^2 + 2760*X;
%Plot Graph
% Create figure
figure1 = figure('Color',[1 1 1]);
% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create scatter
plot(X,Y,'DisplayName','Voltage');
% Create ylabel
ylabel('Strain');
xlabel('Time')
% Find the Given threshold Strain
Strain = 50:10:150;
hold on;
yline(Strain, 'Color', 'r', 'LineWidth', 1);
Xend = numel(X);
for k1 = 1:numel(Strain)
idx = find(diff(sign(Y-Strain(k1))));
for k2 = 1:numel(idx)
idxrng = max(1,idx(k2)-2) : min(Xend,idx(k2)+2);
xval(k1,k2) = interp1(Y(idxrng), X(idxrng), Strain(k1));
end
wdth(k1) = diff(xval(k1,:));
end
Strain = Strain(:);
Width = wdth(:);
Result = table(Strain, Width)
Calculating the full-width-half-maximum would be similar, however it would be necessary to first calculate the half-maximum value based on every value of ‘Strain’ (half the difference between the value of ‘Strain’ and the fixed maximum) and then do the same calculations.
.
18 Comments
Rufus Adjetey
on 9 Jun 2022
Thanks for your answer, But I would love to find the x1 and x2 values for each strain value where the red line intercepts the curve and to compute for each fwhm value = x2-x1. With the way your code is written if strain value is above 200, the fwhm value should be zero instead it gives a non zero value.
So that for each Strain value. I can have Result = (Strain, x1, x2, fwhm)
Many thanks
Star Strider
on 9 Jun 2022
My pleasure!
My code does exactly that for the posted original values for ‘Strain’. The times for each intercept are in the ‘xval’ matrix (each row corresponds to a different ‘Strain’ value), and the widths are in the ‘wdth’ variable. All the results for each ‘Strain’ value are in the ‘Result’ table.
This update tests for an empty value of ‘idx’ and produces the desired result for values above the maximum value of ‘Y’.
X = (0:0.01:0.3);
Y = -9200*(X).^2 + 2760*X;
%Plot Graph
% Create figure
figure1 = figure('Color',[1 1 1]);
% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create scatter
plot(X,Y,'DisplayName','Voltage');
% Create ylabel
ylabel('Strain');
xlabel('Time')
% Find the Given threshold Strain
Strain = 50:10:220;
% hold on;
yline(Strain, 'Color', 'r', 'LineWidth', 1);
Xend = numel(X);
for k1 = 1:numel(Strain)
% Q = Strain(k1)
idx = find(diff(sign(Y-Strain(k1))));
if ~isempty(idx)
for k2 = 1:numel(idx)
idxrng = max(1,idx(k2)-2) : min(Xend,idx(k2)+2);
xval(k1,k2) = interp1(Y(idxrng), X(idxrng), Strain(k1));
end
else
xval(k1,:) = [0 0];
end
wdth(k1,:) = diff(xval(k1,:));
end
Strain = Strain(:);
Width = wdth;
[maxY,ixY] = max(Y);
text(X(ixY)*ones(size(Strain)),Strain, compose('\\Delta t = %.5f',wdth), 'Horiz','center', 'Vert','middle', 'FontSize',9)
Result = table(Strain, Width)
Result = 18×2 table
Strain Width
______ ________
50 0.26122
60 0.25263
70 0.24393
80 0.23482
90 0.22537
100 0.21553
110 0.20518
120 0.19428
130 0.18284
140 0.17038
150 0.15728
160 0.14278
170 0.12649
180 0.10791
190 0.085507
200 0.054435
.
Rufus Adjetey
on 9 Jun 2022
Moved: Star Strider
on 1 Feb 2023
Thank you so much. This helps me understand the code really well. I have been wanting to apply this approach to a larger data set.
So please permit me to ask another question. Could this be done on a similar data like the one attached?
So for every threshhold say at A = 30, delta1A,delta2A,delta3A could be found? Similar for B,C and D?
Many thanks
Rufus Adjetey
on 9 Jun 2022
Also I would like to accept this answer, but I do not see the button to do that. Could you replace the first answer with this please? So I can accept it.
Many thanks
Star Strider
on 9 Jun 2022
Just below my name in my original answer, you should see:
I have asked MathWorks for help in case it is not showing up for some reason. (I do not get see same controls you see, so I cannot determine what the problem is.)
Star Strider
on 9 Jun 2022
Moved: Star Strider
on 1 Feb 2023
My pleasure!
It would be necessary to set up a third loop to define the limits of the peaks, then run my code over each peak. The easiest way to locate the peak centres would be with the findpeaks function. The details of that code would depend on the data.
Rufus Adjetey
on 9 Jun 2022
Moved: Star Strider
on 1 Feb 2023
X = [0.0318400000000000,0.0368000000000000,0.0417600000000000,0.0467200000000000,0.0516800000000000,0.0566400000000000,0.0616000000000000,0.101280000000000,0.106240000000000,0.111200000000000,0.116160000000000,0.121120000000000,0.126080000000000,0.165760000000000,0.170720000000000,0.175680000000000,0.180640000000000,0.185600000000000,0.190560000000000,0.195520000000000,0.230240000000000,0.235200000000000,0.240160000000000,0.245120000000000,0.250080000000000,0.255040000000000,0.260000000000000,0.264960000000000,0.299680000000000,0.304640000000000,0.309600000000000,0.314560000000000,0.319520000000000,0.324480000000000,0.329440000000000,0.364160000000000,0.369120000000000,0.374080000000000,0.379040000000000,0.384000000000000,0.388960000000000,0.393920000000000,0.433600000000000,0.438560000000000,0.443520000000000,0.448480000000000,0.453440000000000,0.458400000000000,0.498080000000000,0.503040000000000,0.508000000000000,0.512960000000000,0.517920000000000,0.522880000000000,0.527840000000000,0.567520000000000,0.572480000000000,0.577440000000000,0.582400000000000,0.587360000000000,0.592320000000000,0.632000000000000,0.636960000000000,0.641920000000000,0.646880000000000,0.651840000000000,0.656800000000000,0.661760000000000,0.696480000000000,0.701440000000000,0.706400000000000,0.711360000000000,0.716320000000000,0.721280000000000,0.726240000000000,0.765920000000000,0.770880000000000,0.775840000000000,0.780800000000000,0.785760000000000,0.790720000000000,0.830400000000000,0.835360000000000,0.840320000000000,0.845280000000000,0.850240000000000,0.855200000000000,0.860160000000000,0.899840000000000,0.904800000000000,0.909760000000000,0.914720000000000,0.919680000000000,0.924640000000000,0.964320000000000,0.969280000000000,0.974240000000000,0.979200000000000,0.984160000000000,0.989120000000000,0.994080000000000,1.03376000000000,1.03872000000000,1.04368000000000,1.04864000000000,1.05360000000000,1.05856000000000,1.09824000000000,1.10320000000000,1.10816000000000,1.11312000000000,1.11808000000000,1.12304000000000,1.12800000000000,1.16272000000000,1.16768000000000,1.17264000000000,1.17760000000000,1.18256000000000,1.18752000000000,1.19248000000000,1.23216000000000,1.23712000000000,1.24208000000000,1.24704000000000,1.25200000000000,1.25696000000000,1.26192000000000,1.29664000000000,1.30160000000000,1.30656000000000,1.31152000000000,1.31648000000000,1.32144000000000,1.32640000000000,1.36608000000000,1.37104000000000,1.37600000000000,1.38096000000000,1.38592000000000,1.39088000000000,1.43056000000000,1.43552000000000,1.44048000000000,1.44544000000000,1.45040000000000,1.45536000000000,1.46032000000000,1.50000000000000,1.50496000000000,1.50992000000000,1.51488000000000,1.51984000000000,1.52480000000000,1.56448000000000,1.56944000000000,1.57440000000000,1.57936000000000,1.58432000000000,1.58928000000000,1.59424000000000,1.63392000000000,1.63888000000000,1.64384000000000,1.64880000000000,1.65376000000000,1.65872000000000,1.69840000000000,1.70336000000000,1.70832000000000,1.71328000000000,1.71824000000000,1.72320000000000,1.72816000000000,1.76288000000000,1.76784000000000,1.77280000000000,1.77776000000000,1.78272000000000,1.78768000000000,1.79264000000000,1.83232000000000,1.83728000000000,1.84224000000000,1.84720000000000,1.85216000000000,1.85712000000000,1.86208000000000,1.89680000000000,1.90176000000000,1.90672000000000,1.91168000000000,1.91664000000000,1.92160000000000,1.92656000000000,1.96624000000000,1.97120000000000,1.97616000000000,1.98112000000000,1.98608000000000,1.99104000000000,2.03072000000000,2.03568000000000,2.04064000000000,2.04560000000000,2.05056000000000,2.05552000000000,2.06048000000000,2.10016000000000,2.10512000000000,2.11008000000000,2.11504000000000,2.12000000000000,2.12496000000000,2.16464000000000,2.16960000000000,2.17456000000000,2.17952000000000,2.18448000000000,2.18944000000000,2.19440000000000,2.22912000000000,2.23408000000000,2.23904000000000,2.24400000000000,2.24896000000000,2.25392000000000,2.25888000000000,2.29856000000000,2.30352000000000,2.30848000000000,2.31344000000000,2.31840000000000,2.32336000000000,2.32832000000000,2.36304000000000,2.36800000000000,2.37296000000000,2.37792000000000,2.38288000000000,2.38784000000000,2.39280000000000,2.43248000000000,2.43744000000000,2.44240000000000,2.44736000000000,2.45232000000000,2.45728000000000,2.49696000000000,2.50192000000000,2.50688000000000,2.51184000000000,2.51680000000000,2.52176000000000,2.52672000000000,2.56640000000000,2.57136000000000,2.57632000000000,2.58128000000000,2.58624000000000,2.59120000000000,2.63088000000000,2.63584000000000,2.64080000000000,2.64576000000000,2.65072000000000,2.65568000000000,2.66064000000000,2.70032000000000,2.70528000000000,2.71024000000000,2.71520000000000,2.72016000000000,2.72512000000000,2.76480000000000,2.76976000000000,2.77472000000000,2.77968000000000,2.78464000000000,2.78960000000000,2.79456000000000,2.82928000000000,2.83424000000000,2.83920000000000,2.84416000000000,2.84912000000000,2.85408000000000,2.85904000000000,2.89872000000000,2.90368000000000,2.90864000000000,2.91360000000000,2.91856000000000,2.92352000000000,2.92848000000000,2.96320000000000,2.96816000000000,2.97312000000000,2.97808000000000,2.98304000000000,2.98800000000000,2.99296000000000,3.03264000000000,3.03760000000000,3.04256000000000,3.04752000000000,3.05248000000000,3.05744000000000,3.09712000000000,3.10208000000000,3.10704000000000,3.11200000000000,3.11696000000000,3.12192000000000,3.12688000000000,3.16656000000000,3.17152000000000,3.17648000000000,3.18144000000000,3.18640000000000,3.19136000000000,3.23104000000000,3.23600000000000,3.24096000000000,3.24592000000000,3.25088000000000,3.25584000000000,3.26080000000000,3.30048000000000,3.30544000000000,3.31040000000000,3.31536000000000,3.32032000000000,3.32528000000000,3.36496000000000,3.36992000000000,3.37488000000000,3.37984000000000,3.38480000000000,3.38976000000000,3.39472000000000,3.42944000000000,3.43440000000000,3.43936000000000,3.44432000000000,3.44928000000000,3.45424000000000,3.45920000000000,3.49888000000000,3.50384000000000,3.50880000000000,3.51376000000000,3.51872000000000,3.52368000000000,3.52864000000000,3.56336000000000,3.56832000000000,3.57328000000000,3.57824000000000,3.58320000000000,3.58816000000000,3.59312000000000,3.63280000000000,3.63776000000000,3.64272000000000,3.64768000000000,3.65264000000000,3.65760000000000,3.69728000000000,3.70224000000000,3.70720000000000,3.71216000000000,3.71712000000000,3.72208000000000,3.72704000000000,3.76672000000000,3.77168000000000,3.77664000000000,3.78160000000000,3.78656000000000,3.79152000000000,3.83120000000000,3.83616000000000,3.84112000000000,3.84608000000000,3.85104000000000,3.85600000000000,3.86096000000000,3.89568000000000,3.90064000000000,3.90560000000000,3.91056000000000,3.91552000000000,3.92048000000000,3.92544000000000,3.96512000000000,3.97008000000000,3.97504000000000,3.98000000000000,3.98496000000000,3.98992000000000,3.99488000000000,4.02960000000000,4.03456000000000,4.03952000000000,4.04448000000000,4.04944000000000,4.05440000000000,4.05936000000000,4.09904000000000,4.10400000000000,4.10896000000000,4.11392000000000,4.11888000000000,4.12384000000000,4.16352000000000,4.16848000000000,4.17344000000000,4.17840000000000,4.18336000000000,4.18832000000000,4.19328000000000,4.23296000000000,4.23792000000000,4.24288000000000,4.24784000000000,4.25280000000000,4.25776000000000,4.29744000000000,4.30240000000000,4.30736000000000,4.31232000000000,4.31728000000000,4.32224000000000,4.32720000000000,4.36688000000000,4.37184000000000,4.37680000000000,4.38176000000000,4.38672000000000,4.39168000000000,4.43136000000000,4.43632000000000,4.44128000000000,4.44624000000000,4.45120000000000,4.45616000000000,4.46112000000000,4.49584000000000,4.50080000000000,4.50576000000000,4.51072000000000,4.51568000000000,4.52064000000000,4.52560000000000,4.56528000000000,4.57024000000000,4.57520000000000,4.58016000000000,4.58512000000000,4.59008000000000,4.59504000000000,4.62976000000000,4.63472000000000,4.63968000000000,4.64464000000000,4.64960000000000,4.65456000000000,4.65952000000000,4.69920000000000,4.70416000000000,4.70912000000000,4.71408000000000,4.71904000000000,4.72400000000000,4.76368000000000,4.76864000000000,4.77360000000000,4.77856000000000,4.78352000000000,4.78848000000000,4.79344000000000,4.83312000000000,4.83808000000000,4.84304000000000,4.84800000000000,4.85296000000000,4.85792000000000,4.89760000000000,4.90256000000000,4.90752000000000,4.91248000000000,4.91744000000000,4.92240000000000,4.92736000000000,4.96704000000000,4.97200000000000,4.97696000000000,4.98192000000000,4.98688000000000,4.99184000000000,5.03152000000000];
Y = [0.0237235890000000,0.0991239370000000,0.141935999000000,0.138421576000000,0.118613010000000,0.0837882730000000,0.0304329420000000,0.132351209000000,0.284429877000000,0.311906275000000,0.291458723000000,0.244812745000000,0.153757240000000,0.0623822420000000,0.429160206000000,0.599130482000000,0.599449975000000,0.558554871000000,0.467499366000000,0.170051383000000,0.0301134490000000,0.613827160000000,0.979327152000000,1.08060643300000,1.03204349700000,0.928847258000000,0.566542196000000,0.0186117010000000,0.479320607000000,1.02501465100000,1.26878781000000,1.24386735600000,1.15089489300000,0.785394901000000,0.130434251000000,0.102318867000000,0.879964829000000,1.36207976600000,1.44642591800000,1.37134506300000,1.10360992900000,0.463345957000000,0.728844640000000,1.42821481700000,1.69467197900000,1.64355309900000,1.46208107500000,0.874213955000000,0.389543074000000,1.36559418900000,1.85250152100000,1.88413132800000,1.77582320100000,1.30201508200000,0.368456536000000,1.09785905500000,1.85761340900000,2.08668989000000,2.00010728700000,1.68444820300000,0.862392714000000,0.694019903000000,1.71863395400000,2.20873621600000,2.20745824400000,2.02854216400000,1.35888483600000,0.186345526000000,0.205834599000000,1.40872574400000,2.18125981800000,2.38669381700000,2.27519076000000,1.79914619000000,0.760793940000000,0.953128726000000,2.00330221700000,2.48765360500000,2.44420255700000,2.17039705600000,1.31319733700000,0.399127864000000,1.67102949700000,2.42183804700000,2.56369293900000,2.43653472500000,1.81735729100000,0.598810989000000,1.17805179800000,2.20713875100000,2.64644162600000,2.57391671500000,2.20330483500000,1.19498492700000,0.550567546000000,1.86240580400000,2.57934809600000,2.66081881100000,2.48509766100000,1.74770781700000,0.419894909000000,1.35505092000000,2.34995212200000,2.71928603000000,2.62567458100000,2.15953429400000,1.05153257000000,0.776449097000000,2.02822267100000,2.66784765700000,2.69724101300000,2.46337213700000,1.62885642100000,0.239061871000000,0.146728394000000,1.53013308400000,2.45762126300000,2.75059634400000,2.63973227300000,2.08860684800000,0.892105563000000,0.956323656000000,2.15953429400000,2.72855132700000,2.71800805800000,2.42726942800000,1.49914226300000,0.0655771720000000,0.342577603000000,1.70010336000000,2.56560989700000,2.77104389600000,2.64356618900000,2.00234373800000,0.731081091000000,1.12916936900000,2.27135684400000,2.78190665800000,2.72631487600000,2.36496829300000,1.35441193400000,0.483793509000000,1.85761340900000,2.64292720300000,2.77391933300000,2.61193638200000,1.88477031400000,0.546733630000000,1.29434725000000,2.35602248900000,2.79564485700000,2.71800805800000,2.27710771800000,1.18635861600000,0.640984065000000,1.98125720000000,2.70363087300000,2.77455831900000,2.56209547400000,1.74738832400000,0.361747183000000,1.44674541100000,2.44707799400000,2.81705088800000,2.71641059300000,2.19180308700000,1.02309769300000,0.848974008000000,2.11736121800000,2.75379127400000,2.77232186800000,2.50490622700000,1.61511822200000,0.186026033000000,0.211265980000000,1.61671568700000,2.53589704800000,2.81737038100000,2.70075543600000,2.09627468000000,0.856002854000000,1.03172400400000,2.23493464200000,2.79915928000000,2.77615578400000,2.45314836100000,1.47422180900000,0.0157362640000000,0.390501553000000,1.77294776400000,2.63334241300000,2.81928733900000,2.67423751700000,1.98924452500000,0.687949536000000,1.21319602800000,2.34739617800000,2.83653996100000,2.77232186800000,2.37742852000000,1.31447530900000,0.528842022000000,1.94195956100000,2.72887082000000,2.84548576500000,2.66337475500000,1.87742197500000,0.505838526000000,1.36207976600000,2.45346785400000,2.88222746000000,2.79628384300000,2.30522310200000,1.15217286500000,0.724691231000000,2.08093901600000,2.80810508400000,2.86337737300000,2.62503559500000,1.74962477500000,0.324366502000000,0.0617432560000000,1.53907888800000,2.54164792200000,2.90299450500000,2.79883978700000,2.22215492200000,0.984758533000000,0.917345510000000,2.21065317400000,2.85379258300000,2.86114092200000,2.56784634800000,1.60776988300000,0.142255492000000,0.278040017000000,1.69339400700000,2.62631356700000,2.88286644600000,2.76593200800000,2.11001287900000,0.808078904000000,1.07996744700000,2.29340186100000,2.86816976800000,2.83685945400000,2.47902729400000,1.44035555100000,0.420853388000000,1.84036078700000,2.70650631000000,2.87967151600000,2.73046828500000,1.98828604600000,0.633955219000000,1.26399541500000,2.38733280300000,2.88733934800000,2.81737038100000,2.38893026800000,1.27805310700000,0.568459154000000,1.99467590600000,2.76976592400000,2.87104520500000,2.67583498200000,1.85537695800000,0.451205223000000,1.42054698500000,2.47870780100000,2.89820211000000,2.80778559100000,2.28605352200000,1.11095826800000,0.792104254000000,2.13046043100000,2.82631618500000,2.86657230300000,2.61896522800000,1.71416105200000,0.277081538000000,0.125322363000000,1.59179523300000,2.57807012400000,2.91321828100000,2.80554914000000,2.20106838400000,0.942904950000000,0.966227939000000,2.24867284100000,2.86273838700000,2.85858497800000,2.54484285200000,1.56208238400000,0.0863442170000000,0.323727516000000,1.74706883100000,2.66593069900000,2.90075805400000,2.77232186800000,2.08732887600000,0.772615181000000,1.14514401900000,2.33525544400000,2.88957579900000,2.84708323000000,2.46944250400000,1.39882146100000,0.470374803000000,1.88860423000000,2.73845561000000,2.89372920800000,2.72855132700000,1.95090536500000,0.592421129000000,1.31511429500000,2.43174233000000,2.91098183000000,2.83366452400000,2.37838699900000,1.23588003100000,0.635872177000000,2.03461253100000,2.79596435000000,2.87903253000000,2.66912562900000,1.81895475600000,0.397849892000000,1.47166586500000,2.51576898900000,2.91769118300000,2.81800936700000,2.27359329500000,1.07166062900000,0.848335022000000,2.16496567500000,2.84995866700000,2.87551810700000,2.60394905700000,1.67134899000000,0.215738882000000,0.189540456000000,1.64163614100000,2.60426855000000,2.91769118300000,2.80522964700000,2.17518945100000,0.899453902000000,1.02373667900000,2.28253909900000,2.88638086900000,2.86944774000000,2.53525806200000,1.52885511200000,0.0342668580000000,0.359830225000000,1.78988089300000,2.68861470200000,2.88797833400000,2.75634721800000,2.05474059000000,0.715745427000000,1.20041630800000,2.36560727900000,2.90331399800000,2.85059765300000,2.44739748700000,1.35888483600000,0.505199540000000,1.94419601200000,2.75986164100000,2.89436819400000,2.71704957900000,1.92534592500000,0.547372616000000,1.35920432900000,2.46081619300000,2.91321828100000,2.83238655200000,2.35474451700000,1.19051202500000,0.698173312000000,2.07231270500000,2.81609240900000,2.88701985500000,2.65890185300000,1.78892241400000,0.355037830000000,0.0186117010000000,1.52502119600000,2.54707930300000,2.92280307100000,2.81832886000000,2.25090929200000,1.02597313000000,0.901051367000000,2.20809723000000,2.85251461100000,2.86912824700000,2.58733542100000,1.63428780200000,0.160786086000000,0.239700857000000,1.67486341300000,2.62695255300000,2.90555044900000,2.78893550400000,2.13940623500000,0.838750232000000,1.06399279700000,2.30554259500000,2.88957579900000,2.86369686600000,2.51576898900000,1.48284812000000,0.400405836000000,1.83908281500000,2.71449363500000,2.90299450500000,2.75219380900000,2.02215230400000,0.672294379000000,1.25153518800000,2.38637432400000,2.91066233700000,2.84644424400000,2.42758892100000,1.32310162000000,0.547692109000000,1.99180046900000,2.78446260200000,2.89756312400000,2.69883847800000,1.89307713200000,0.494017285000000,1.41671306900000,2.49691890200000,2.92376155000000,2.83749844000000,2.33493595100000,1.16367461300000,0.762071912000000,2.12087564100000,2.83909590500000,2.89053427800000,2.65091452800000,1.75793159300000,0.311267289000000,0.0802738500000000,1.57614007600000,2.57902860300000,2.92951242400000,2.82248226900000,2.23205920500000,0.982841575000000,0.947377852000000,2.24164399500000,2.86880875400000,2.86753078200000,2.57072178500000,1.60489444600000,0.123085912000000,0.299765541000000,1.73365012500000,2.66241627600000,2.92024712700000,2.79149144800000,2.11672223200000,0.800411072000000,1.12246001600000,2.34196479700000,2.89724363100000,2.85954345700000,2.49596042300000,1.44706490400000,0.443217898000000,1.88892372300000,2.73781662400000,2.90331399800000,2.74197003300000,1.99371742700000,0.631399275000000,1.29402775700000,2.42247703300000,2.92024712700000,2.85123663900000,2.40394643900000,1.28124803700000,0.603603384000000,2.03173709400000,2.80203471700000,2.89564616600000,2.68605875800000,1.85729391600000,0.446093335000000,1.46016411700000,2.52567327200000,2.91673270400000,2.82376024100000,2.29627729800000,1.11127776100000,0.818941666000000];
% Create scatter
plot(X,Y,'DisplayName','Voltage',...
'Marker','NONE');
% Create ylabel
ylabel('Voltage [V]');
xlabel('No. of Cycles');
% Find the Given threshold Voltage
for v = 1:0.5:2.5
hold on;
yline(v, 'Color', 'r', 'LineWidth', 1);
end
Please see the above data as an example, for the different thresholds, that is v values, I would want to calculate the delat values betwwemn each peaks.
many thanks
Star Strider
on 9 Jun 2022
Moved: Star Strider
on 1 Feb 2023
Try this —
X = [0.0318400000000000,0.0368000000000000,0.0417600000000000,0.0467200000000000,0.0516800000000000,0.0566400000000000,0.0616000000000000,0.101280000000000,0.106240000000000,0.111200000000000,0.116160000000000,0.121120000000000,0.126080000000000,0.165760000000000,0.170720000000000,0.175680000000000,0.180640000000000,0.185600000000000,0.190560000000000,0.195520000000000,0.230240000000000,0.235200000000000,0.240160000000000,0.245120000000000,0.250080000000000,0.255040000000000,0.260000000000000,0.264960000000000,0.299680000000000,0.304640000000000,0.309600000000000,0.314560000000000,0.319520000000000,0.324480000000000,0.329440000000000,0.364160000000000,0.369120000000000,0.374080000000000,0.379040000000000,0.384000000000000,0.388960000000000,0.393920000000000,0.433600000000000,0.438560000000000,0.443520000000000,0.448480000000000,0.453440000000000,0.458400000000000,0.498080000000000,0.503040000000000,0.508000000000000,0.512960000000000,0.517920000000000,0.522880000000000,0.527840000000000,0.567520000000000,0.572480000000000,0.577440000000000,0.582400000000000,0.587360000000000,0.592320000000000,0.632000000000000,0.636960000000000,0.641920000000000,0.646880000000000,0.651840000000000,0.656800000000000,0.661760000000000,0.696480000000000,0.701440000000000,0.706400000000000,0.711360000000000,0.716320000000000,0.721280000000000,0.726240000000000,0.765920000000000,0.770880000000000,0.775840000000000,0.780800000000000,0.785760000000000,0.790720000000000,0.830400000000000,0.835360000000000,0.840320000000000,0.845280000000000,0.850240000000000,0.855200000000000,0.860160000000000,0.899840000000000,0.904800000000000,0.909760000000000,0.914720000000000,0.919680000000000,0.924640000000000,0.964320000000000,0.969280000000000,0.974240000000000,0.979200000000000,0.984160000000000,0.989120000000000,0.994080000000000,1.03376000000000,1.03872000000000,1.04368000000000,1.04864000000000,1.05360000000000,1.05856000000000,1.09824000000000,1.10320000000000,1.10816000000000,1.11312000000000,1.11808000000000,1.12304000000000,1.12800000000000,1.16272000000000,1.16768000000000,1.17264000000000,1.17760000000000,1.18256000000000,1.18752000000000,1.19248000000000,1.23216000000000,1.23712000000000,1.24208000000000,1.24704000000000,1.25200000000000,1.25696000000000,1.26192000000000,1.29664000000000,1.30160000000000,1.30656000000000,1.31152000000000,1.31648000000000,1.32144000000000,1.32640000000000,1.36608000000000,1.37104000000000,1.37600000000000,1.38096000000000,1.38592000000000,1.39088000000000,1.43056000000000,1.43552000000000,1.44048000000000,1.44544000000000,1.45040000000000,1.45536000000000,1.46032000000000,1.50000000000000,1.50496000000000,1.50992000000000,1.51488000000000,1.51984000000000,1.52480000000000,1.56448000000000,1.56944000000000,1.57440000000000,1.57936000000000,1.58432000000000,1.58928000000000,1.59424000000000,1.63392000000000,1.63888000000000,1.64384000000000,1.64880000000000,1.65376000000000,1.65872000000000,1.69840000000000,1.70336000000000,1.70832000000000,1.71328000000000,1.71824000000000,1.72320000000000,1.72816000000000,1.76288000000000,1.76784000000000,1.77280000000000,1.77776000000000,1.78272000000000,1.78768000000000,1.79264000000000,1.83232000000000,1.83728000000000,1.84224000000000,1.84720000000000,1.85216000000000,1.85712000000000,1.86208000000000,1.89680000000000,1.90176000000000,1.90672000000000,1.91168000000000,1.91664000000000,1.92160000000000,1.92656000000000,1.96624000000000,1.97120000000000,1.97616000000000,1.98112000000000,1.98608000000000,1.99104000000000,2.03072000000000,2.03568000000000,2.04064000000000,2.04560000000000,2.05056000000000,2.05552000000000,2.06048000000000,2.10016000000000,2.10512000000000,2.11008000000000,2.11504000000000,2.12000000000000,2.12496000000000,2.16464000000000,2.16960000000000,2.17456000000000,2.17952000000000,2.18448000000000,2.18944000000000,2.19440000000000,2.22912000000000,2.23408000000000,2.23904000000000,2.24400000000000,2.24896000000000,2.25392000000000,2.25888000000000,2.29856000000000,2.30352000000000,2.30848000000000,2.31344000000000,2.31840000000000,2.32336000000000,2.32832000000000,2.36304000000000,2.36800000000000,2.37296000000000,2.37792000000000,2.38288000000000,2.38784000000000,2.39280000000000,2.43248000000000,2.43744000000000,2.44240000000000,2.44736000000000,2.45232000000000,2.45728000000000,2.49696000000000,2.50192000000000,2.50688000000000,2.51184000000000,2.51680000000000,2.52176000000000,2.52672000000000,2.56640000000000,2.57136000000000,2.57632000000000,2.58128000000000,2.58624000000000,2.59120000000000,2.63088000000000,2.63584000000000,2.64080000000000,2.64576000000000,2.65072000000000,2.65568000000000,2.66064000000000,2.70032000000000,2.70528000000000,2.71024000000000,2.71520000000000,2.72016000000000,2.72512000000000,2.76480000000000,2.76976000000000,2.77472000000000,2.77968000000000,2.78464000000000,2.78960000000000,2.79456000000000,2.82928000000000,2.83424000000000,2.83920000000000,2.84416000000000,2.84912000000000,2.85408000000000,2.85904000000000,2.89872000000000,2.90368000000000,2.90864000000000,2.91360000000000,2.91856000000000,2.92352000000000,2.92848000000000,2.96320000000000,2.96816000000000,2.97312000000000,2.97808000000000,2.98304000000000,2.98800000000000,2.99296000000000,3.03264000000000,3.03760000000000,3.04256000000000,3.04752000000000,3.05248000000000,3.05744000000000,3.09712000000000,3.10208000000000,3.10704000000000,3.11200000000000,3.11696000000000,3.12192000000000,3.12688000000000,3.16656000000000,3.17152000000000,3.17648000000000,3.18144000000000,3.18640000000000,3.19136000000000,3.23104000000000,3.23600000000000,3.24096000000000,3.24592000000000,3.25088000000000,3.25584000000000,3.26080000000000,3.30048000000000,3.30544000000000,3.31040000000000,3.31536000000000,3.32032000000000,3.32528000000000,3.36496000000000,3.36992000000000,3.37488000000000,3.37984000000000,3.38480000000000,3.38976000000000,3.39472000000000,3.42944000000000,3.43440000000000,3.43936000000000,3.44432000000000,3.44928000000000,3.45424000000000,3.45920000000000,3.49888000000000,3.50384000000000,3.50880000000000,3.51376000000000,3.51872000000000,3.52368000000000,3.52864000000000,3.56336000000000,3.56832000000000,3.57328000000000,3.57824000000000,3.58320000000000,3.58816000000000,3.59312000000000,3.63280000000000,3.63776000000000,3.64272000000000,3.64768000000000,3.65264000000000,3.65760000000000,3.69728000000000,3.70224000000000,3.70720000000000,3.71216000000000,3.71712000000000,3.72208000000000,3.72704000000000,3.76672000000000,3.77168000000000,3.77664000000000,3.78160000000000,3.78656000000000,3.79152000000000,3.83120000000000,3.83616000000000,3.84112000000000,3.84608000000000,3.85104000000000,3.85600000000000,3.86096000000000,3.89568000000000,3.90064000000000,3.90560000000000,3.91056000000000,3.91552000000000,3.92048000000000,3.92544000000000,3.96512000000000,3.97008000000000,3.97504000000000,3.98000000000000,3.98496000000000,3.98992000000000,3.99488000000000,4.02960000000000,4.03456000000000,4.03952000000000,4.04448000000000,4.04944000000000,4.05440000000000,4.05936000000000,4.09904000000000,4.10400000000000,4.10896000000000,4.11392000000000,4.11888000000000,4.12384000000000,4.16352000000000,4.16848000000000,4.17344000000000,4.17840000000000,4.18336000000000,4.18832000000000,4.19328000000000,4.23296000000000,4.23792000000000,4.24288000000000,4.24784000000000,4.25280000000000,4.25776000000000,4.29744000000000,4.30240000000000,4.30736000000000,4.31232000000000,4.31728000000000,4.32224000000000,4.32720000000000,4.36688000000000,4.37184000000000,4.37680000000000,4.38176000000000,4.38672000000000,4.39168000000000,4.43136000000000,4.43632000000000,4.44128000000000,4.44624000000000,4.45120000000000,4.45616000000000,4.46112000000000,4.49584000000000,4.50080000000000,4.50576000000000,4.51072000000000,4.51568000000000,4.52064000000000,4.52560000000000,4.56528000000000,4.57024000000000,4.57520000000000,4.58016000000000,4.58512000000000,4.59008000000000,4.59504000000000,4.62976000000000,4.63472000000000,4.63968000000000,4.64464000000000,4.64960000000000,4.65456000000000,4.65952000000000,4.69920000000000,4.70416000000000,4.70912000000000,4.71408000000000,4.71904000000000,4.72400000000000,4.76368000000000,4.76864000000000,4.77360000000000,4.77856000000000,4.78352000000000,4.78848000000000,4.79344000000000,4.83312000000000,4.83808000000000,4.84304000000000,4.84800000000000,4.85296000000000,4.85792000000000,4.89760000000000,4.90256000000000,4.90752000000000,4.91248000000000,4.91744000000000,4.92240000000000,4.92736000000000,4.96704000000000,4.97200000000000,4.97696000000000,4.98192000000000,4.98688000000000,4.99184000000000,5.03152000000000];
Y = [0.0237235890000000,0.0991239370000000,0.141935999000000,0.138421576000000,0.118613010000000,0.0837882730000000,0.0304329420000000,0.132351209000000,0.284429877000000,0.311906275000000,0.291458723000000,0.244812745000000,0.153757240000000,0.0623822420000000,0.429160206000000,0.599130482000000,0.599449975000000,0.558554871000000,0.467499366000000,0.170051383000000,0.0301134490000000,0.613827160000000,0.979327152000000,1.08060643300000,1.03204349700000,0.928847258000000,0.566542196000000,0.0186117010000000,0.479320607000000,1.02501465100000,1.26878781000000,1.24386735600000,1.15089489300000,0.785394901000000,0.130434251000000,0.102318867000000,0.879964829000000,1.36207976600000,1.44642591800000,1.37134506300000,1.10360992900000,0.463345957000000,0.728844640000000,1.42821481700000,1.69467197900000,1.64355309900000,1.46208107500000,0.874213955000000,0.389543074000000,1.36559418900000,1.85250152100000,1.88413132800000,1.77582320100000,1.30201508200000,0.368456536000000,1.09785905500000,1.85761340900000,2.08668989000000,2.00010728700000,1.68444820300000,0.862392714000000,0.694019903000000,1.71863395400000,2.20873621600000,2.20745824400000,2.02854216400000,1.35888483600000,0.186345526000000,0.205834599000000,1.40872574400000,2.18125981800000,2.38669381700000,2.27519076000000,1.79914619000000,0.760793940000000,0.953128726000000,2.00330221700000,2.48765360500000,2.44420255700000,2.17039705600000,1.31319733700000,0.399127864000000,1.67102949700000,2.42183804700000,2.56369293900000,2.43653472500000,1.81735729100000,0.598810989000000,1.17805179800000,2.20713875100000,2.64644162600000,2.57391671500000,2.20330483500000,1.19498492700000,0.550567546000000,1.86240580400000,2.57934809600000,2.66081881100000,2.48509766100000,1.74770781700000,0.419894909000000,1.35505092000000,2.34995212200000,2.71928603000000,2.62567458100000,2.15953429400000,1.05153257000000,0.776449097000000,2.02822267100000,2.66784765700000,2.69724101300000,2.46337213700000,1.62885642100000,0.239061871000000,0.146728394000000,1.53013308400000,2.45762126300000,2.75059634400000,2.63973227300000,2.08860684800000,0.892105563000000,0.956323656000000,2.15953429400000,2.72855132700000,2.71800805800000,2.42726942800000,1.49914226300000,0.0655771720000000,0.342577603000000,1.70010336000000,2.56560989700000,2.77104389600000,2.64356618900000,2.00234373800000,0.731081091000000,1.12916936900000,2.27135684400000,2.78190665800000,2.72631487600000,2.36496829300000,1.35441193400000,0.483793509000000,1.85761340900000,2.64292720300000,2.77391933300000,2.61193638200000,1.88477031400000,0.546733630000000,1.29434725000000,2.35602248900000,2.79564485700000,2.71800805800000,2.27710771800000,1.18635861600000,0.640984065000000,1.98125720000000,2.70363087300000,2.77455831900000,2.56209547400000,1.74738832400000,0.361747183000000,1.44674541100000,2.44707799400000,2.81705088800000,2.71641059300000,2.19180308700000,1.02309769300000,0.848974008000000,2.11736121800000,2.75379127400000,2.77232186800000,2.50490622700000,1.61511822200000,0.186026033000000,0.211265980000000,1.61671568700000,2.53589704800000,2.81737038100000,2.70075543600000,2.09627468000000,0.856002854000000,1.03172400400000,2.23493464200000,2.79915928000000,2.77615578400000,2.45314836100000,1.47422180900000,0.0157362640000000,0.390501553000000,1.77294776400000,2.63334241300000,2.81928733900000,2.67423751700000,1.98924452500000,0.687949536000000,1.21319602800000,2.34739617800000,2.83653996100000,2.77232186800000,2.37742852000000,1.31447530900000,0.528842022000000,1.94195956100000,2.72887082000000,2.84548576500000,2.66337475500000,1.87742197500000,0.505838526000000,1.36207976600000,2.45346785400000,2.88222746000000,2.79628384300000,2.30522310200000,1.15217286500000,0.724691231000000,2.08093901600000,2.80810508400000,2.86337737300000,2.62503559500000,1.74962477500000,0.324366502000000,0.0617432560000000,1.53907888800000,2.54164792200000,2.90299450500000,2.79883978700000,2.22215492200000,0.984758533000000,0.917345510000000,2.21065317400000,2.85379258300000,2.86114092200000,2.56784634800000,1.60776988300000,0.142255492000000,0.278040017000000,1.69339400700000,2.62631356700000,2.88286644600000,2.76593200800000,2.11001287900000,0.808078904000000,1.07996744700000,2.29340186100000,2.86816976800000,2.83685945400000,2.47902729400000,1.44035555100000,0.420853388000000,1.84036078700000,2.70650631000000,2.87967151600000,2.73046828500000,1.98828604600000,0.633955219000000,1.26399541500000,2.38733280300000,2.88733934800000,2.81737038100000,2.38893026800000,1.27805310700000,0.568459154000000,1.99467590600000,2.76976592400000,2.87104520500000,2.67583498200000,1.85537695800000,0.451205223000000,1.42054698500000,2.47870780100000,2.89820211000000,2.80778559100000,2.28605352200000,1.11095826800000,0.792104254000000,2.13046043100000,2.82631618500000,2.86657230300000,2.61896522800000,1.71416105200000,0.277081538000000,0.125322363000000,1.59179523300000,2.57807012400000,2.91321828100000,2.80554914000000,2.20106838400000,0.942904950000000,0.966227939000000,2.24867284100000,2.86273838700000,2.85858497800000,2.54484285200000,1.56208238400000,0.0863442170000000,0.323727516000000,1.74706883100000,2.66593069900000,2.90075805400000,2.77232186800000,2.08732887600000,0.772615181000000,1.14514401900000,2.33525544400000,2.88957579900000,2.84708323000000,2.46944250400000,1.39882146100000,0.470374803000000,1.88860423000000,2.73845561000000,2.89372920800000,2.72855132700000,1.95090536500000,0.592421129000000,1.31511429500000,2.43174233000000,2.91098183000000,2.83366452400000,2.37838699900000,1.23588003100000,0.635872177000000,2.03461253100000,2.79596435000000,2.87903253000000,2.66912562900000,1.81895475600000,0.397849892000000,1.47166586500000,2.51576898900000,2.91769118300000,2.81800936700000,2.27359329500000,1.07166062900000,0.848335022000000,2.16496567500000,2.84995866700000,2.87551810700000,2.60394905700000,1.67134899000000,0.215738882000000,0.189540456000000,1.64163614100000,2.60426855000000,2.91769118300000,2.80522964700000,2.17518945100000,0.899453902000000,1.02373667900000,2.28253909900000,2.88638086900000,2.86944774000000,2.53525806200000,1.52885511200000,0.0342668580000000,0.359830225000000,1.78988089300000,2.68861470200000,2.88797833400000,2.75634721800000,2.05474059000000,0.715745427000000,1.20041630800000,2.36560727900000,2.90331399800000,2.85059765300000,2.44739748700000,1.35888483600000,0.505199540000000,1.94419601200000,2.75986164100000,2.89436819400000,2.71704957900000,1.92534592500000,0.547372616000000,1.35920432900000,2.46081619300000,2.91321828100000,2.83238655200000,2.35474451700000,1.19051202500000,0.698173312000000,2.07231270500000,2.81609240900000,2.88701985500000,2.65890185300000,1.78892241400000,0.355037830000000,0.0186117010000000,1.52502119600000,2.54707930300000,2.92280307100000,2.81832886000000,2.25090929200000,1.02597313000000,0.901051367000000,2.20809723000000,2.85251461100000,2.86912824700000,2.58733542100000,1.63428780200000,0.160786086000000,0.239700857000000,1.67486341300000,2.62695255300000,2.90555044900000,2.78893550400000,2.13940623500000,0.838750232000000,1.06399279700000,2.30554259500000,2.88957579900000,2.86369686600000,2.51576898900000,1.48284812000000,0.400405836000000,1.83908281500000,2.71449363500000,2.90299450500000,2.75219380900000,2.02215230400000,0.672294379000000,1.25153518800000,2.38637432400000,2.91066233700000,2.84644424400000,2.42758892100000,1.32310162000000,0.547692109000000,1.99180046900000,2.78446260200000,2.89756312400000,2.69883847800000,1.89307713200000,0.494017285000000,1.41671306900000,2.49691890200000,2.92376155000000,2.83749844000000,2.33493595100000,1.16367461300000,0.762071912000000,2.12087564100000,2.83909590500000,2.89053427800000,2.65091452800000,1.75793159300000,0.311267289000000,0.0802738500000000,1.57614007600000,2.57902860300000,2.92951242400000,2.82248226900000,2.23205920500000,0.982841575000000,0.947377852000000,2.24164399500000,2.86880875400000,2.86753078200000,2.57072178500000,1.60489444600000,0.123085912000000,0.299765541000000,1.73365012500000,2.66241627600000,2.92024712700000,2.79149144800000,2.11672223200000,0.800411072000000,1.12246001600000,2.34196479700000,2.89724363100000,2.85954345700000,2.49596042300000,1.44706490400000,0.443217898000000,1.88892372300000,2.73781662400000,2.90331399800000,2.74197003300000,1.99371742700000,0.631399275000000,1.29402775700000,2.42247703300000,2.92024712700000,2.85123663900000,2.40394643900000,1.28124803700000,0.603603384000000,2.03173709400000,2.80203471700000,2.89564616600000,2.68605875800000,1.85729391600000,0.446093335000000,1.46016411700000,2.52567327200000,2.91673270400000,2.82376024100000,2.29627729800000,1.11127776100000,0.818941666000000];
Strain = 1:0.5:2.5;
[pks,plocs] = findpeaks(Y);
[vys,vlocs] = findpeaks(-Y);
vlocs = [1 vlocs numel(Y)];
for k1 = 1:numel(vlocs)-1
idx = vlocs(k1) : vlocs(k1+1);
[Width(k1,:),Results{k1}] = interpStrain(X(idx), Y(idx), Strain);
figure
plot(X(idx), Y(idx))
yline(Strain, 'Color', 'r', 'LineWidth', 1);
text(X(plocs(k1))*ones(size(Strain)),Strain, compose('\\Delta t = %.5f',Width(k1,:)), 'Horiz','center', 'Vert','middle', 'FontSize',9)
xlabel('No. of Cycles');
ylabel('Voltage [V]');
title(sprintf('Peak #%3d',k1))
fprintf('\nPeak #%3d —\n',k1)
Strain_Width_Table = Results{k1}
end
Peak # 1 —
Strain_Width_Table = 4×2 table
Strain Width
______ _____
1 0
1.5 0
2 0
2.5 0
Peak # 2 —
Strain_Width_Table = 4×2 table
Strain Width
______ _____
1 0
1.5 0
2 0
2.5 0
Peak # 3 —
Strain_Width_Table = 4×2 table
Strain Width
______ _____
1 0
1.5 0
2 0
2.5 0
Peak # 4 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.010448
1.5 0
2 0
2.5 0
Peak # 5 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.017155
1.5 0
2 0
2.5 0
Peak # 6 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.019408
1.5 0
2 0
2.5 0
Peak # 7 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.021816
1.5 0.012507
2 0
2.5 0
Peak # 8 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.023302
1.5 0.016398
2 0
2.5 0
Peak # 9 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.029293
1.5 0.018328
2 0.0068387
2.5 0
Peak # 10 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.024837
1.5 0.019853
2 0.012244
2.5 0
Peak # 11 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.025343
1.5 0.020683
2 0.013951
2.5 0
Peak # 12 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.038175
1.5 0.021136
2 0.015882
2.5 0
Peak # 13 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.025784
1.5 0.021799
2 0.016204
2.5 0.0047115
Peak # 14 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.049003
1.5 0.021748
2 0.016878
2.5 0.0076027
Peak # 15 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.025894
1.5 0.022136
2 0.017191
2.5 0.0089005
Peak # 16 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.047299
1.5 0.02207
2 0.017339
2.5 0.0092422
Peak # 17 —
Strain_Width_Table = 4×2 table
Strain Width
______ _________
1 0.026159
1.5 0.022393
2 0.017746
2.5 0.0094446
Peak # 18 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026253
1.5 0.022388
2 0.017695
2.5 0.01046
Peak # 19 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026347
1.5 0.022554
2 0.017821
2.5 0.010671
Peak # 20 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026309
1.5 0.022531
2 0.018131
2.5 0.011407
Peak # 21 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.053828
1.5 0.022475
2 0.01785
2.5 0.010805
Peak # 22 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026216
1.5 0.022557
2 0.018155
2.5 0.011586
Peak # 23 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.053982
1.5 0.022413
2 0.017803
2.5 0.010748
Peak # 24 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026147
1.5 0.022507
2 0.018173
2.5 0.011696
Peak # 25 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.046402
1.5 0.022512
2 0.017911
2.5 0.011257
Peak # 26 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026344
1.5 0.022654
2 0.018153
2.5 0.011925
Peak # 27 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026401
1.5 0.022636
2 0.018157
2.5 0.011761
Peak # 28 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.033576
1.5 0.022739
2 0.018144
2.5 0.01183
Peak # 29 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026384
1.5 0.022684
2 0.018453
2.5 0.01195
Peak # 30 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.056789
1.5 0.02268
2 0.01816
2.5 0.011793
Peak # 31 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026319
1.5 0.022756
2 0.018701
2.5 0.012394
Peak # 32 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.055705
1.5 0.022677
2 0.018254
2.5 0.012374
Peak # 33 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026402
1.5 0.022833
2 0.018717
2.5 0.01273
Peak # 34 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026549
1.5 0.022866
2 0.01845
2.5 0.012696
Peak # 35 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.02654
1.5 0.02293
2 0.018622
2.5 0.012999
Peak # 36 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026499
1.5 0.022842
2 0.018629
2.5 0.012603
Peak # 37 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.05361
1.5 0.022798
2 0.018367
2.5 0.012806
Peak # 38 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026396
1.5 0.022818
2 0.018848
2.5 0.012643
Peak # 39 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.056975
1.5 0.022767
2 0.018327
2.5 0.012477
Peak # 40 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026321
1.5 0.022816
2 0.018932
2.5 0.012709
Peak # 41 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.055823
1.5 0.022785
2 0.018331
2.5 0.012594
Peak # 42 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026494
1.5 0.022916
2 0.018757
2.5 0.012898
Peak # 43 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026577
1.5 0.022914
2 0.01858
2.5 0.01282
Peak # 44 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026559
1.5 0.022944
2 0.018592
2.5 0.013076
Peak # 45 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026546
1.5 0.022917
2 0.018804
2.5 0.012788
Peak # 46 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.057305
1.5 0.022852
2 0.018452
2.5 0.013005
Peak # 47 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.02642
1.5 0.022845
2 0.018877
2.5 0.012769
Peak # 48 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.057701
1.5 0.022832
2 0.01844
2.5 0.012849
Peak # 49 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026367
1.5 0.022849
2 0.018906
2.5 0.012835
Peak # 50 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.054962
1.5 0.022898
2 0.018459
2.5 0.012892
Peak # 51 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026516
1.5 0.022929
2 0.018714
2.5 0.013007
Peak # 52 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026601
1.5 0.022949
2 0.018675
2.5 0.01286
Peak # 53 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.034134
1.5 0.023019
2 0.018631
2.5 0.013268
Peak # 54 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026487
1.5 0.0229
2 0.018883
2.5 0.012773
Peak # 55 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.057889
1.5 0.022882
2 0.018475
2.5 0.012993
Peak # 56 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026425
1.5 0.022902
2 0.019033
2.5 0.01286
Peak # 57 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.057711
1.5 0.022848
2 0.018466
2.5 0.012942
Peak # 58 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.02644
1.5 0.022905
2 0.018898
2.5 0.012934
Peak # 59 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.034779
1.5 0.022963
2 0.018551
2.5 0.012931
Peak # 60 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.02656
1.5 0.022979
2 0.018726
2.5 0.013088
Peak # 61 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026517
1.5 0.022883
2 0.018678
2.5 0.012788
Peak # 62 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.053774
1.5 0.022976
2 0.018577
2.5 0.013304
Peak # 63 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026489
1.5 0.022928
2 0.01901
2.5 0.012849
Peak # 64 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.058565
1.5 0.02292
2 0.018489
2.5 0.012948
Peak # 65 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026413
1.5 0.022923
2 0.019131
2.5 0.012924
Peak # 66 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.058892
1.5 0.022993
2 0.01858
2.5 0.013215
Peak # 67 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.02653
1.5 0.022991
2 0.018937
2.5 0.0131
Peak # 68 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026642
1.5 0.022999
2 0.018665
2.5 0.01302
Peak # 69 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026623
1.5 0.023033
2 0.018737
2.5 0.0132
Peak # 70 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026586
1.5 0.022972
2 0.018857
2.5 0.01293
Peak # 71 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.05756
1.5 0.023014
2 0.018616
2.5 0.013413
Peak # 72 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026508
1.5 0.022972
2 0.019149
2.5 0.012914
Peak # 73 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.058876
1.5 0.022928
2 0.018522
2.5 0.013042
Peak # 74 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.026436
1.5 0.022943
2 0.019096
2.5 0.012978
Peak # 75 —
Strain_Width_Table = 4×2 table
Strain Width
______ ________
1 0.05791
1.5 0.022988
2 0.018567
2.5 0.013084
% Create scatter
plot(X,Y,'DisplayName','Voltage',...
'Marker','NONE');
% Create ylabel
ylabel('Voltage [V]');
xlabel('No. of Cycles');
% Find the Given threshold Voltage
yline(Strain, 'Color', 'r', 'LineWidth', 1);
function [Width,TW] = interpStrain(X,Y,Strain)
Strain = Strain(:);
Xend = numel(X);
for k1 = 1:numel(Strain)
% Q = Strain(k1)
idx = find(diff(sign(Y-Strain(k1))));
if ~isempty(idx)
for k2 = 1:numel(idx)
idxrng = max(1,idx(k2)-1) : min(Xend,idx(k2)+1);
xval(k1,k2) = interp1(Y(idxrng), X(idxrng), Strain(k1));
end
else
xval(k1,:) = [0 0];
end
Width(k1,:) = diff(xval(k1,:));
end
TW = table(Strain,Width);
end
I created my ‘interpStrain’ function from my original code, then just called it in the loop for each set of data. The data limits are defined initially in the second findpeaks call:
[vys,vlocs] = findpeaks(-Y);
vlocs = [1 vlocs numel(Y)];
and the the index range is assigned in the loop:
idx = vlocs(k1) : vlocs(k1+1);
then the (X,Y) variables in this range are passed to my ‘interpStrain’ function that returns the ‘Width’ vector and a table of the results for each peak.
My code should be robust to all data sets that are similar to this one.
.
Rufus Adjetey
on 10 Jun 2022
Moved: Star Strider
on 1 Feb 2023
Thank you so much. That works so well for the initial data set.
I tried a more reasonable data set. But it gives me an error.
Could you please help.
Many thanks.
Data Set is Below
x1 = 0:0.01:0.3;
x2 = 0.3:0.01:0.6;
x3 = 0.6:0.01:0.9;
y1 = (-43.11*x1.^2) + (12.9333*x1);
y2 = (-71.1111111111111*x2.^2) + (64*x2)-12.8000000000000;
y3 = (-120*x3.^2) + (180*x3) -64.8;
X = [x1 x2 x3]';
Y = [y1 y2 y3]';
Strain = 0.5:0.5:2.5;
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in ass2 (line 17)
vlocs = [1 vlocs numel(Y)];
Star Strider
on 10 Jun 2022
Moved: Star Strider
on 1 Feb 2023
One of the value crossing values in the ‘interpStrain’ function was returning more than one value. (Although these data are not noisy, my code apparently had a difficult time with these data since one value crossing returned two index values rather than the one it should have. That could also be a problem with noisy data. If any data are noisy, it will be necessary to smooth noisy data to remove any noise that is present, since my code is not robust to noise. The sgolayfilt function is likely best for that.)
x1 = 0:0.01:0.3;
x2 = 0.3:0.01:0.6;
x3 = 0.6:0.01:0.9;
y1 = (-43.11*x1.^2) + (12.9333*x1);
y2 = (-71.1111111111111*x2.^2) + (64*x2)-12.8000000000000;
y3 = (-120*x3.^2) + (180*x3) -64.8;
X = [x1 x2 x3]';
Y = [y1 y2 y3]';
Strain = 0.5:0.5:2.5;
figure
plot(X,Y)
yline(Strain,'-r')
X = X(:).'; % Data Must Be Row Vectors
Y = Y(:).'; % Data Must Be Row Vectors
[pks,plocs] = findpeaks(Y);
[vys,vlocs] = findpeaks(-Y);
vlocs = unique([1 vlocs numel(Y)])
vlocs = 1×4
1 32 62 93
for k1 = 1:numel(vlocs)-1
idx = vlocs(k1) : vlocs(k1+1);
[Width(k1,:),Results{k1}] = interpStrain(X(idx), Y(idx), Strain);
figure
plot(X(idx), Y(idx))
yline(Strain, 'Color', 'r', 'LineWidth', 1);
text(X(plocs(k1))*ones(size(Strain)),Strain, compose('\\Delta t = %.5f',Width(k1,:)), 'Horiz','center', 'Vert','middle', 'FontSize',9)
xlabel('No. of Cycles');
ylabel('Voltage [V]');
title(sprintf('Peak #%3d',k1))
ylim([min(ylim) 3])
fprintf('\nPeak #%3d —\n',k1)
Strain_Width_Table = Results{k1}
end
Peak # 1 —
Strain_Width_Table = 5×2 table
Strain Width
______ ______
0.5 0.2086
1 0
1.5 0
2 0
2.5 0
Peak # 2 —
Strain_Width_Table = 5×2 table
Strain Width
______ ________
0.5 0.24855
1 0.18355
1.5 0.074464
2 0
2.5 0
Peak # 3 —
Strain_Width_Table = 5×2 table
Strain Width
______ ________
0.5 0.27062
1 0.23797
1.5 0.2
2 0.15244
2.5 0.081481
function [Width,TW] = interpStrain(X,Y,Strain)
Strain = Strain(:);
Xend = numel(X);
for k1 = 1:numel(Strain)
% fprintf(repmat('-',1,20))
% k1
% Q = Strain(k1)
idx1 = find(diff(sign(Y-Strain(k1))));
idx = [min(idx1) max(idx1)];
if ~isempty(idx)
for k2 = 1:numel(idx)
idxrng = max(1,idx(k2)-1) : min(Xend,idx(k2)+1);
xval(k1,k2) = interp1(Y(idxrng), X(idxrng), Strain(k1));
end
else
xval(k1,:) = [0 0];
end
Width(k1,:) = diff(xval(k1,:));
end
TW = table(Strain,Width);
end
That should work and be reasonably robust. I cannot guarantee that it is robust to all problems with any data.
.
Rufus Adjetey
on 10 Jun 2022
Moved: Star Strider
on 1 Feb 2023
Thank you so much. I truly appreciate your effort and time.
Rufus Adjetey
on 1 Feb 2023
Moved: Star Strider
on 1 Feb 2023
Hi Star Strider,
I want to covert the cell data into a table of arrays. I tried to concatenate the cell but it would not permit me giving an error "Duplicate table variable name: 'Width'."
Results = 1x12 cell which contains 10 x 2 table in each cell
Question: Since all the second column of each table is named Width Is it possible to give it a variable name say 1 to 12?
A1 = cellfun(@(x) x(:,2),Results,'un',0);
Cvert = cat(2,A1{:});
Star Strider
on 1 Feb 2023
Changing the ‘TW’ assignment that write the tables to:
TW = table(Width, 'RowNames',compose('%.1f',Strain), 'VariableNames',{sprintf('Width_Peak_%03d',k)});
allows:
Cvert = cat(2,Results{:});
to horizontally concatenate the tables.
Try this —
X = [0.0318400000000000,0.0368000000000000,0.0417600000000000,0.0467200000000000,0.0516800000000000,0.0566400000000000,0.0616000000000000,0.101280000000000,0.106240000000000,0.111200000000000,0.116160000000000,0.121120000000000,0.126080000000000,0.165760000000000,0.170720000000000,0.175680000000000,0.180640000000000,0.185600000000000,0.190560000000000,0.195520000000000,0.230240000000000,0.235200000000000,0.240160000000000,0.245120000000000,0.250080000000000,0.255040000000000,0.260000000000000,0.264960000000000,0.299680000000000,0.304640000000000,0.309600000000000,0.314560000000000,0.319520000000000,0.324480000000000,0.329440000000000,0.364160000000000,0.369120000000000,0.374080000000000,0.379040000000000,0.384000000000000,0.388960000000000,0.393920000000000,0.433600000000000,0.438560000000000,0.443520000000000,0.448480000000000,0.453440000000000,0.458400000000000,0.498080000000000,0.503040000000000,0.508000000000000,0.512960000000000,0.517920000000000,0.522880000000000,0.527840000000000,0.567520000000000,0.572480000000000,0.577440000000000,0.582400000000000,0.587360000000000,0.592320000000000,0.632000000000000,0.636960000000000,0.641920000000000,0.646880000000000,0.651840000000000,0.656800000000000,0.661760000000000,0.696480000000000,0.701440000000000,0.706400000000000,0.711360000000000,0.716320000000000,0.721280000000000,0.726240000000000,0.765920000000000,0.770880000000000,0.775840000000000,0.780800000000000,0.785760000000000,0.790720000000000,0.830400000000000,0.835360000000000,0.840320000000000,0.845280000000000,0.850240000000000,0.855200000000000,0.860160000000000,0.899840000000000,0.904800000000000,0.909760000000000,0.914720000000000,0.919680000000000,0.924640000000000,0.964320000000000,0.969280000000000,0.974240000000000,0.979200000000000,0.984160000000000,0.989120000000000,0.994080000000000,1.03376000000000,1.03872000000000,1.04368000000000,1.04864000000000,1.05360000000000,1.05856000000000,1.09824000000000,1.10320000000000,1.10816000000000,1.11312000000000,1.11808000000000,1.12304000000000,1.12800000000000,1.16272000000000,1.16768000000000,1.17264000000000,1.17760000000000,1.18256000000000,1.18752000000000,1.19248000000000,1.23216000000000,1.23712000000000,1.24208000000000,1.24704000000000,1.25200000000000,1.25696000000000,1.26192000000000,1.29664000000000,1.30160000000000,1.30656000000000,1.31152000000000,1.31648000000000,1.32144000000000,1.32640000000000,1.36608000000000,1.37104000000000,1.37600000000000,1.38096000000000,1.38592000000000,1.39088000000000,1.43056000000000,1.43552000000000,1.44048000000000,1.44544000000000,1.45040000000000,1.45536000000000,1.46032000000000,1.50000000000000,1.50496000000000,1.50992000000000,1.51488000000000,1.51984000000000,1.52480000000000,1.56448000000000,1.56944000000000,1.57440000000000,1.57936000000000,1.58432000000000,1.58928000000000,1.59424000000000,1.63392000000000,1.63888000000000,1.64384000000000,1.64880000000000,1.65376000000000,1.65872000000000,1.69840000000000,1.70336000000000,1.70832000000000,1.71328000000000,1.71824000000000,1.72320000000000,1.72816000000000,1.76288000000000,1.76784000000000,1.77280000000000,1.77776000000000,1.78272000000000,1.78768000000000,1.79264000000000,1.83232000000000,1.83728000000000,1.84224000000000,1.84720000000000,1.85216000000000,1.85712000000000,1.86208000000000,1.89680000000000,1.90176000000000,1.90672000000000,1.91168000000000,1.91664000000000,1.92160000000000,1.92656000000000,1.96624000000000,1.97120000000000,1.97616000000000,1.98112000000000,1.98608000000000,1.99104000000000,2.03072000000000,2.03568000000000,2.04064000000000,2.04560000000000,2.05056000000000,2.05552000000000,2.06048000000000,2.10016000000000,2.10512000000000,2.11008000000000,2.11504000000000,2.12000000000000,2.12496000000000,2.16464000000000,2.16960000000000,2.17456000000000,2.17952000000000,2.18448000000000,2.18944000000000,2.19440000000000,2.22912000000000,2.23408000000000,2.23904000000000,2.24400000000000,2.24896000000000,2.25392000000000,2.25888000000000,2.29856000000000,2.30352000000000,2.30848000000000,2.31344000000000,2.31840000000000,2.32336000000000,2.32832000000000,2.36304000000000,2.36800000000000,2.37296000000000,2.37792000000000,2.38288000000000,2.38784000000000,2.39280000000000,2.43248000000000,2.43744000000000,2.44240000000000,2.44736000000000,2.45232000000000,2.45728000000000,2.49696000000000,2.50192000000000,2.50688000000000,2.51184000000000,2.51680000000000,2.52176000000000,2.52672000000000,2.56640000000000,2.57136000000000,2.57632000000000,2.58128000000000,2.58624000000000,2.59120000000000,2.63088000000000,2.63584000000000,2.64080000000000,2.64576000000000,2.65072000000000,2.65568000000000,2.66064000000000,2.70032000000000,2.70528000000000,2.71024000000000,2.71520000000000,2.72016000000000,2.72512000000000,2.76480000000000,2.76976000000000,2.77472000000000,2.77968000000000,2.78464000000000,2.78960000000000,2.79456000000000,2.82928000000000,2.83424000000000,2.83920000000000,2.84416000000000,2.84912000000000,2.85408000000000,2.85904000000000,2.89872000000000,2.90368000000000,2.90864000000000,2.91360000000000,2.91856000000000,2.92352000000000,2.92848000000000,2.96320000000000,2.96816000000000,2.97312000000000,2.97808000000000,2.98304000000000,2.98800000000000,2.99296000000000,3.03264000000000,3.03760000000000,3.04256000000000,3.04752000000000,3.05248000000000,3.05744000000000,3.09712000000000,3.10208000000000,3.10704000000000,3.11200000000000,3.11696000000000,3.12192000000000,3.12688000000000,3.16656000000000,3.17152000000000,3.17648000000000,3.18144000000000,3.18640000000000,3.19136000000000,3.23104000000000,3.23600000000000,3.24096000000000,3.24592000000000,3.25088000000000,3.25584000000000,3.26080000000000,3.30048000000000,3.30544000000000,3.31040000000000,3.31536000000000,3.32032000000000,3.32528000000000,3.36496000000000,3.36992000000000,3.37488000000000,3.37984000000000,3.38480000000000,3.38976000000000,3.39472000000000,3.42944000000000,3.43440000000000,3.43936000000000,3.44432000000000,3.44928000000000,3.45424000000000,3.45920000000000,3.49888000000000,3.50384000000000,3.50880000000000,3.51376000000000,3.51872000000000,3.52368000000000,3.52864000000000,3.56336000000000,3.56832000000000,3.57328000000000,3.57824000000000,3.58320000000000,3.58816000000000,3.59312000000000,3.63280000000000,3.63776000000000,3.64272000000000,3.64768000000000,3.65264000000000,3.65760000000000,3.69728000000000,3.70224000000000,3.70720000000000,3.71216000000000,3.71712000000000,3.72208000000000,3.72704000000000,3.76672000000000,3.77168000000000,3.77664000000000,3.78160000000000,3.78656000000000,3.79152000000000,3.83120000000000,3.83616000000000,3.84112000000000,3.84608000000000,3.85104000000000,3.85600000000000,3.86096000000000,3.89568000000000,3.90064000000000,3.90560000000000,3.91056000000000,3.91552000000000,3.92048000000000,3.92544000000000,3.96512000000000,3.97008000000000,3.97504000000000,3.98000000000000,3.98496000000000,3.98992000000000,3.99488000000000,4.02960000000000,4.03456000000000,4.03952000000000,4.04448000000000,4.04944000000000,4.05440000000000,4.05936000000000,4.09904000000000,4.10400000000000,4.10896000000000,4.11392000000000,4.11888000000000,4.12384000000000,4.16352000000000,4.16848000000000,4.17344000000000,4.17840000000000,4.18336000000000,4.18832000000000,4.19328000000000,4.23296000000000,4.23792000000000,4.24288000000000,4.24784000000000,4.25280000000000,4.25776000000000,4.29744000000000,4.30240000000000,4.30736000000000,4.31232000000000,4.31728000000000,4.32224000000000,4.32720000000000,4.36688000000000,4.37184000000000,4.37680000000000,4.38176000000000,4.38672000000000,4.39168000000000,4.43136000000000,4.43632000000000,4.44128000000000,4.44624000000000,4.45120000000000,4.45616000000000,4.46112000000000,4.49584000000000,4.50080000000000,4.50576000000000,4.51072000000000,4.51568000000000,4.52064000000000,4.52560000000000,4.56528000000000,4.57024000000000,4.57520000000000,4.58016000000000,4.58512000000000,4.59008000000000,4.59504000000000,4.62976000000000,4.63472000000000,4.63968000000000,4.64464000000000,4.64960000000000,4.65456000000000,4.65952000000000,4.69920000000000,4.70416000000000,4.70912000000000,4.71408000000000,4.71904000000000,4.72400000000000,4.76368000000000,4.76864000000000,4.77360000000000,4.77856000000000,4.78352000000000,4.78848000000000,4.79344000000000,4.83312000000000,4.83808000000000,4.84304000000000,4.84800000000000,4.85296000000000,4.85792000000000,4.89760000000000,4.90256000000000,4.90752000000000,4.91248000000000,4.91744000000000,4.92240000000000,4.92736000000000,4.96704000000000,4.97200000000000,4.97696000000000,4.98192000000000,4.98688000000000,4.99184000000000,5.03152000000000];
Y = [0.0237235890000000,0.0991239370000000,0.141935999000000,0.138421576000000,0.118613010000000,0.0837882730000000,0.0304329420000000,0.132351209000000,0.284429877000000,0.311906275000000,0.291458723000000,0.244812745000000,0.153757240000000,0.0623822420000000,0.429160206000000,0.599130482000000,0.599449975000000,0.558554871000000,0.467499366000000,0.170051383000000,0.0301134490000000,0.613827160000000,0.979327152000000,1.08060643300000,1.03204349700000,0.928847258000000,0.566542196000000,0.0186117010000000,0.479320607000000,1.02501465100000,1.26878781000000,1.24386735600000,1.15089489300000,0.785394901000000,0.130434251000000,0.102318867000000,0.879964829000000,1.36207976600000,1.44642591800000,1.37134506300000,1.10360992900000,0.463345957000000,0.728844640000000,1.42821481700000,1.69467197900000,1.64355309900000,1.46208107500000,0.874213955000000,0.389543074000000,1.36559418900000,1.85250152100000,1.88413132800000,1.77582320100000,1.30201508200000,0.368456536000000,1.09785905500000,1.85761340900000,2.08668989000000,2.00010728700000,1.68444820300000,0.862392714000000,0.694019903000000,1.71863395400000,2.20873621600000,2.20745824400000,2.02854216400000,1.35888483600000,0.186345526000000,0.205834599000000,1.40872574400000,2.18125981800000,2.38669381700000,2.27519076000000,1.79914619000000,0.760793940000000,0.953128726000000,2.00330221700000,2.48765360500000,2.44420255700000,2.17039705600000,1.31319733700000,0.399127864000000,1.67102949700000,2.42183804700000,2.56369293900000,2.43653472500000,1.81735729100000,0.598810989000000,1.17805179800000,2.20713875100000,2.64644162600000,2.57391671500000,2.20330483500000,1.19498492700000,0.550567546000000,1.86240580400000,2.57934809600000,2.66081881100000,2.48509766100000,1.74770781700000,0.419894909000000,1.35505092000000,2.34995212200000,2.71928603000000,2.62567458100000,2.15953429400000,1.05153257000000,0.776449097000000,2.02822267100000,2.66784765700000,2.69724101300000,2.46337213700000,1.62885642100000,0.239061871000000,0.146728394000000,1.53013308400000,2.45762126300000,2.75059634400000,2.63973227300000,2.08860684800000,0.892105563000000,0.956323656000000,2.15953429400000,2.72855132700000,2.71800805800000,2.42726942800000,1.49914226300000,0.0655771720000000,0.342577603000000,1.70010336000000,2.56560989700000,2.77104389600000,2.64356618900000,2.00234373800000,0.731081091000000,1.12916936900000,2.27135684400000,2.78190665800000,2.72631487600000,2.36496829300000,1.35441193400000,0.483793509000000,1.85761340900000,2.64292720300000,2.77391933300000,2.61193638200000,1.88477031400000,0.546733630000000,1.29434725000000,2.35602248900000,2.79564485700000,2.71800805800000,2.27710771800000,1.18635861600000,0.640984065000000,1.98125720000000,2.70363087300000,2.77455831900000,2.56209547400000,1.74738832400000,0.361747183000000,1.44674541100000,2.44707799400000,2.81705088800000,2.71641059300000,2.19180308700000,1.02309769300000,0.848974008000000,2.11736121800000,2.75379127400000,2.77232186800000,2.50490622700000,1.61511822200000,0.186026033000000,0.211265980000000,1.61671568700000,2.53589704800000,2.81737038100000,2.70075543600000,2.09627468000000,0.856002854000000,1.03172400400000,2.23493464200000,2.79915928000000,2.77615578400000,2.45314836100000,1.47422180900000,0.0157362640000000,0.390501553000000,1.77294776400000,2.63334241300000,2.81928733900000,2.67423751700000,1.98924452500000,0.687949536000000,1.21319602800000,2.34739617800000,2.83653996100000,2.77232186800000,2.37742852000000,1.31447530900000,0.528842022000000,1.94195956100000,2.72887082000000,2.84548576500000,2.66337475500000,1.87742197500000,0.505838526000000,1.36207976600000,2.45346785400000,2.88222746000000,2.79628384300000,2.30522310200000,1.15217286500000,0.724691231000000,2.08093901600000,2.80810508400000,2.86337737300000,2.62503559500000,1.74962477500000,0.324366502000000,0.0617432560000000,1.53907888800000,2.54164792200000,2.90299450500000,2.79883978700000,2.22215492200000,0.984758533000000,0.917345510000000,2.21065317400000,2.85379258300000,2.86114092200000,2.56784634800000,1.60776988300000,0.142255492000000,0.278040017000000,1.69339400700000,2.62631356700000,2.88286644600000,2.76593200800000,2.11001287900000,0.808078904000000,1.07996744700000,2.29340186100000,2.86816976800000,2.83685945400000,2.47902729400000,1.44035555100000,0.420853388000000,1.84036078700000,2.70650631000000,2.87967151600000,2.73046828500000,1.98828604600000,0.633955219000000,1.26399541500000,2.38733280300000,2.88733934800000,2.81737038100000,2.38893026800000,1.27805310700000,0.568459154000000,1.99467590600000,2.76976592400000,2.87104520500000,2.67583498200000,1.85537695800000,0.451205223000000,1.42054698500000,2.47870780100000,2.89820211000000,2.80778559100000,2.28605352200000,1.11095826800000,0.792104254000000,2.13046043100000,2.82631618500000,2.86657230300000,2.61896522800000,1.71416105200000,0.277081538000000,0.125322363000000,1.59179523300000,2.57807012400000,2.91321828100000,2.80554914000000,2.20106838400000,0.942904950000000,0.966227939000000,2.24867284100000,2.86273838700000,2.85858497800000,2.54484285200000,1.56208238400000,0.0863442170000000,0.323727516000000,1.74706883100000,2.66593069900000,2.90075805400000,2.77232186800000,2.08732887600000,0.772615181000000,1.14514401900000,2.33525544400000,2.88957579900000,2.84708323000000,2.46944250400000,1.39882146100000,0.470374803000000,1.88860423000000,2.73845561000000,2.89372920800000,2.72855132700000,1.95090536500000,0.592421129000000,1.31511429500000,2.43174233000000,2.91098183000000,2.83366452400000,2.37838699900000,1.23588003100000,0.635872177000000,2.03461253100000,2.79596435000000,2.87903253000000,2.66912562900000,1.81895475600000,0.397849892000000,1.47166586500000,2.51576898900000,2.91769118300000,2.81800936700000,2.27359329500000,1.07166062900000,0.848335022000000,2.16496567500000,2.84995866700000,2.87551810700000,2.60394905700000,1.67134899000000,0.215738882000000,0.189540456000000,1.64163614100000,2.60426855000000,2.91769118300000,2.80522964700000,2.17518945100000,0.899453902000000,1.02373667900000,2.28253909900000,2.88638086900000,2.86944774000000,2.53525806200000,1.52885511200000,0.0342668580000000,0.359830225000000,1.78988089300000,2.68861470200000,2.88797833400000,2.75634721800000,2.05474059000000,0.715745427000000,1.20041630800000,2.36560727900000,2.90331399800000,2.85059765300000,2.44739748700000,1.35888483600000,0.505199540000000,1.94419601200000,2.75986164100000,2.89436819400000,2.71704957900000,1.92534592500000,0.547372616000000,1.35920432900000,2.46081619300000,2.91321828100000,2.83238655200000,2.35474451700000,1.19051202500000,0.698173312000000,2.07231270500000,2.81609240900000,2.88701985500000,2.65890185300000,1.78892241400000,0.355037830000000,0.0186117010000000,1.52502119600000,2.54707930300000,2.92280307100000,2.81832886000000,2.25090929200000,1.02597313000000,0.901051367000000,2.20809723000000,2.85251461100000,2.86912824700000,2.58733542100000,1.63428780200000,0.160786086000000,0.239700857000000,1.67486341300000,2.62695255300000,2.90555044900000,2.78893550400000,2.13940623500000,0.838750232000000,1.06399279700000,2.30554259500000,2.88957579900000,2.86369686600000,2.51576898900000,1.48284812000000,0.400405836000000,1.83908281500000,2.71449363500000,2.90299450500000,2.75219380900000,2.02215230400000,0.672294379000000,1.25153518800000,2.38637432400000,2.91066233700000,2.84644424400000,2.42758892100000,1.32310162000000,0.547692109000000,1.99180046900000,2.78446260200000,2.89756312400000,2.69883847800000,1.89307713200000,0.494017285000000,1.41671306900000,2.49691890200000,2.92376155000000,2.83749844000000,2.33493595100000,1.16367461300000,0.762071912000000,2.12087564100000,2.83909590500000,2.89053427800000,2.65091452800000,1.75793159300000,0.311267289000000,0.0802738500000000,1.57614007600000,2.57902860300000,2.92951242400000,2.82248226900000,2.23205920500000,0.982841575000000,0.947377852000000,2.24164399500000,2.86880875400000,2.86753078200000,2.57072178500000,1.60489444600000,0.123085912000000,0.299765541000000,1.73365012500000,2.66241627600000,2.92024712700000,2.79149144800000,2.11672223200000,0.800411072000000,1.12246001600000,2.34196479700000,2.89724363100000,2.85954345700000,2.49596042300000,1.44706490400000,0.443217898000000,1.88892372300000,2.73781662400000,2.90331399800000,2.74197003300000,1.99371742700000,0.631399275000000,1.29402775700000,2.42247703300000,2.92024712700000,2.85123663900000,2.40394643900000,1.28124803700000,0.603603384000000,2.03173709400000,2.80203471700000,2.89564616600000,2.68605875800000,1.85729391600000,0.446093335000000,1.46016411700000,2.52567327200000,2.91673270400000,2.82376024100000,2.29627729800000,1.11127776100000,0.818941666000000];
Strain = 1:0.5:2.5;
[pks,plocs] = findpeaks(Y);
[vys,vlocs] = findpeaks(-Y);
vlocs = [1 vlocs numel(Y)];
for k1 = 1:numel(vlocs)-1
idx = vlocs(k1) : vlocs(k1+1);
[Width(k1,:),Results{k1}] = interpStrain(X(idx), Y(idx), Strain, k1);
figure
plot(X(idx), Y(idx))
yline(Strain, 'Color', 'r', 'LineWidth', 1);
text(X(plocs(k1))*ones(size(Strain)),Strain, compose('\\Delta t = %.5f',Width(k1,:)), 'Horiz','center', 'Vert','middle', 'FontSize',9)
xlabel('No. of Cycles');
ylabel('Voltage [V]');
title(sprintf('Peak #%3d',k1))
fprintf('\nPeak #%3d —\n',k1)
Strain_Width_Table = Results{k1}
end
Peak # 1 —
Strain_Width_Table = 4×1 table
Width_Peak_001
______________
1.0 0
1.5 0
2.0 0
2.5 0
Peak # 2 —
Strain_Width_Table = 4×1 table
Width_Peak_002
______________
1.0 0
1.5 0
2.0 0
2.5 0
Peak # 3 —
Strain_Width_Table = 4×1 table
Width_Peak_003
______________
1.0 0
1.5 0
2.0 0
2.5 0
Peak # 4 —
Strain_Width_Table = 4×1 table
Width_Peak_004
______________
1.0 0.010448
1.5 0
2.0 0
2.5 0
Peak # 5 —
Strain_Width_Table = 4×1 table
Width_Peak_005
______________
1.0 0.017155
1.5 0
2.0 0
2.5 0
Peak # 6 —
Strain_Width_Table = 4×1 table
Width_Peak_006
______________
1.0 0.019408
1.5 0
2.0 0
2.5 0
Peak # 7 —
Strain_Width_Table = 4×1 table
Width_Peak_007
______________
1.0 0.021816
1.5 0.012507
2.0 0
2.5 0
Peak # 8 —
Strain_Width_Table = 4×1 table
Width_Peak_008
______________
1.0 0.023302
1.5 0.016398
2.0 0
2.5 0
Peak # 9 —
Strain_Width_Table = 4×1 table
Width_Peak_009
______________
1.0 0.029293
1.5 0.018328
2.0 0.0068387
2.5 0
Peak # 10 —
Strain_Width_Table = 4×1 table
Width_Peak_010
______________
1.0 0.024837
1.5 0.019853
2.0 0.012244
2.5 0
Peak # 11 —
Strain_Width_Table = 4×1 table
Width_Peak_011
______________
1.0 0.025343
1.5 0.020683
2.0 0.013951
2.5 0
Peak # 12 —
Strain_Width_Table = 4×1 table
Width_Peak_012
______________
1.0 0.038175
1.5 0.021136
2.0 0.015882
2.5 0
Peak # 13 —
Strain_Width_Table = 4×1 table
Width_Peak_013
______________
1.0 0.025784
1.5 0.021799
2.0 0.016204
2.5 0.0047115
Peak # 14 —
Strain_Width_Table = 4×1 table
Width_Peak_014
______________
1.0 0.049003
1.5 0.021748
2.0 0.016878
2.5 0.0076027
Peak # 15 —
Strain_Width_Table = 4×1 table
Width_Peak_015
______________
1.0 0.025894
1.5 0.022136
2.0 0.017191
2.5 0.0089005
Peak # 16 —
Strain_Width_Table = 4×1 table
Width_Peak_016
______________
1.0 0.047299
1.5 0.02207
2.0 0.017339
2.5 0.0092422
Peak # 17 —
Strain_Width_Table = 4×1 table
Width_Peak_017
______________
1.0 0.026159
1.5 0.022393
2.0 0.017746
2.5 0.0094446
Peak # 18 —
Strain_Width_Table = 4×1 table
Width_Peak_018
______________
1.0 0.026253
1.5 0.022388
2.0 0.017695
2.5 0.01046
Peak # 19 —
Strain_Width_Table = 4×1 table
Width_Peak_019
______________
1.0 0.026347
1.5 0.022554
2.0 0.017821
2.5 0.010671
Peak # 20 —
Strain_Width_Table = 4×1 table
Width_Peak_020
______________
1.0 0.026309
1.5 0.022531
2.0 0.018131
2.5 0.011407
Peak # 21 —
Strain_Width_Table = 4×1 table
Width_Peak_021
______________
1.0 0.053828
1.5 0.022475
2.0 0.01785
2.5 0.010805
Peak # 22 —
Strain_Width_Table = 4×1 table
Width_Peak_022
______________
1.0 0.026216
1.5 0.022557
2.0 0.018155
2.5 0.011586
Peak # 23 —
Strain_Width_Table = 4×1 table
Width_Peak_023
______________
1.0 0.053982
1.5 0.022413
2.0 0.017803
2.5 0.010748
Peak # 24 —
Strain_Width_Table = 4×1 table
Width_Peak_024
______________
1.0 0.026147
1.5 0.022507
2.0 0.018173
2.5 0.011696
Peak # 25 —
Strain_Width_Table = 4×1 table
Width_Peak_025
______________
1.0 0.046402
1.5 0.022512
2.0 0.017911
2.5 0.011257
Peak # 26 —
Strain_Width_Table = 4×1 table
Width_Peak_026
______________
1.0 0.026344
1.5 0.022654
2.0 0.018153
2.5 0.011925
Peak # 27 —
Strain_Width_Table = 4×1 table
Width_Peak_027
______________
1.0 0.026401
1.5 0.022636
2.0 0.018157
2.5 0.011761
Peak # 28 —
Strain_Width_Table = 4×1 table
Width_Peak_028
______________
1.0 0.033576
1.5 0.022739
2.0 0.018144
2.5 0.01183
Peak # 29 —
Strain_Width_Table = 4×1 table
Width_Peak_029
______________
1.0 0.026384
1.5 0.022684
2.0 0.018453
2.5 0.01195
Peak # 30 —
Strain_Width_Table = 4×1 table
Width_Peak_030
______________
1.0 0.056789
1.5 0.02268
2.0 0.01816
2.5 0.011793
Peak # 31 —
Strain_Width_Table = 4×1 table
Width_Peak_031
______________
1.0 0.026319
1.5 0.022756
2.0 0.018701
2.5 0.012394
Peak # 32 —
Strain_Width_Table = 4×1 table
Width_Peak_032
______________
1.0 0.055705
1.5 0.022677
2.0 0.018254
2.5 0.012374
Peak # 33 —
Strain_Width_Table = 4×1 table
Width_Peak_033
______________
1.0 0.026402
1.5 0.022833
2.0 0.018717
2.5 0.01273
Peak # 34 —
Strain_Width_Table = 4×1 table
Width_Peak_034
______________
1.0 0.026549
1.5 0.022866
2.0 0.01845
2.5 0.012696
Peak # 35 —
Strain_Width_Table = 4×1 table
Width_Peak_035
______________
1.0 0.02654
1.5 0.02293
2.0 0.018622
2.5 0.012999
Peak # 36 —
Strain_Width_Table = 4×1 table
Width_Peak_036
______________
1.0 0.026499
1.5 0.022842
2.0 0.018629
2.5 0.012603
Peak # 37 —
Strain_Width_Table = 4×1 table
Width_Peak_037
______________
1.0 0.05361
1.5 0.022798
2.0 0.018367
2.5 0.012806
Peak # 38 —
Strain_Width_Table = 4×1 table
Width_Peak_038
______________
1.0 0.026396
1.5 0.022818
2.0 0.018848
2.5 0.012643
Peak # 39 —
Strain_Width_Table = 4×1 table
Width_Peak_039
______________
1.0 0.056975
1.5 0.022767
2.0 0.018327
2.5 0.012477
Peak # 40 —
Strain_Width_Table = 4×1 table
Width_Peak_040
______________
1.0 0.026321
1.5 0.022816
2.0 0.018932
2.5 0.012709
Peak # 41 —
Strain_Width_Table = 4×1 table
Width_Peak_041
______________
1.0 0.055823
1.5 0.022785
2.0 0.018331
2.5 0.012594
Peak # 42 —
Strain_Width_Table = 4×1 table
Width_Peak_042
______________
1.0 0.026494
1.5 0.022916
2.0 0.018757
2.5 0.012898
Peak # 43 —
Strain_Width_Table = 4×1 table
Width_Peak_043
______________
1.0 0.026577
1.5 0.022914
2.0 0.01858
2.5 0.01282
Peak # 44 —
Strain_Width_Table = 4×1 table
Width_Peak_044
______________
1.0 0.026559
1.5 0.022944
2.0 0.018592
2.5 0.013076
Peak # 45 —
Strain_Width_Table = 4×1 table
Width_Peak_045
______________
1.0 0.026546
1.5 0.022917
2.0 0.018804
2.5 0.012788
Peak # 46 —
Strain_Width_Table = 4×1 table
Width_Peak_046
______________
1.0 0.057305
1.5 0.022852
2.0 0.018452
2.5 0.013005
Peak # 47 —
Strain_Width_Table = 4×1 table
Width_Peak_047
______________
1.0 0.02642
1.5 0.022845
2.0 0.018877
2.5 0.012769
Peak # 48 —
Strain_Width_Table = 4×1 table
Width_Peak_048
______________
1.0 0.057701
1.5 0.022832
2.0 0.01844
2.5 0.012849
Peak # 49 —
Strain_Width_Table = 4×1 table
Width_Peak_049
______________
1.0 0.026367
1.5 0.022849
2.0 0.018906
2.5 0.012835
Peak # 50 —
Strain_Width_Table = 4×1 table
Width_Peak_050
______________
1.0 0.054962
1.5 0.022898
2.0 0.018459
2.5 0.012892
Peak # 51 —
Strain_Width_Table = 4×1 table
Width_Peak_051
______________
1.0 0.026516
1.5 0.022929
2.0 0.018714
2.5 0.013007
Peak # 52 —
Strain_Width_Table = 4×1 table
Width_Peak_052
______________
1.0 0.026601
1.5 0.022949
2.0 0.018675
2.5 0.01286
Peak # 53 —
Strain_Width_Table = 4×1 table
Width_Peak_053
______________
1.0 0.034134
1.5 0.023019
2.0 0.018631
2.5 0.013268
Peak # 54 —
Strain_Width_Table = 4×1 table
Width_Peak_054
______________
1.0 0.026487
1.5 0.0229
2.0 0.018883
2.5 0.012773
Peak # 55 —
Strain_Width_Table = 4×1 table
Width_Peak_055
______________
1.0 0.057889
1.5 0.022882
2.0 0.018475
2.5 0.012993
Peak # 56 —
Strain_Width_Table = 4×1 table
Width_Peak_056
______________
1.0 0.026425
1.5 0.022902
2.0 0.019033
2.5 0.01286
Peak # 57 —
Strain_Width_Table = 4×1 table
Width_Peak_057
______________
1.0 0.057711
1.5 0.022848
2.0 0.018466
2.5 0.012942
Peak # 58 —
Strain_Width_Table = 4×1 table
Width_Peak_058
______________
1.0 0.02644
1.5 0.022905
2.0 0.018898
2.5 0.012934
Peak # 59 —
Strain_Width_Table = 4×1 table
Width_Peak_059
______________
1.0 0.034779
1.5 0.022963
2.0 0.018551
2.5 0.012931
Peak # 60 —
Strain_Width_Table = 4×1 table
Width_Peak_060
______________
1.0 0.02656
1.5 0.022979
2.0 0.018726
2.5 0.013088
Peak # 61 —
Strain_Width_Table = 4×1 table
Width_Peak_061
______________
1.0 0.026517
1.5 0.022883
2.0 0.018678
2.5 0.012788
Peak # 62 —
Strain_Width_Table = 4×1 table
Width_Peak_062
______________
1.0 0.053774
1.5 0.022976
2.0 0.018577
2.5 0.013304
Peak # 63 —
Strain_Width_Table = 4×1 table
Width_Peak_063
______________
1.0 0.026489
1.5 0.022928
2.0 0.01901
2.5 0.012849
Peak # 64 —
Strain_Width_Table = 4×1 table
Width_Peak_064
______________
1.0 0.058565
1.5 0.02292
2.0 0.018489
2.5 0.012948
Peak # 65 —
Strain_Width_Table = 4×1 table
Width_Peak_065
______________
1.0 0.026413
1.5 0.022923
2.0 0.019131
2.5 0.012924
Peak # 66 —
Strain_Width_Table = 4×1 table
Width_Peak_066
______________
1.0 0.058892
1.5 0.022993
2.0 0.01858
2.5 0.013215
Peak # 67 —
Strain_Width_Table = 4×1 table
Width_Peak_067
______________
1.0 0.02653
1.5 0.022991
2.0 0.018937
2.5 0.0131
Peak # 68 —
Strain_Width_Table = 4×1 table
Width_Peak_068
______________
1.0 0.026642
1.5 0.022999
2.0 0.018665
2.5 0.01302
Peak # 69 —
Strain_Width_Table = 4×1 table
Width_Peak_069
______________
1.0 0.026623
1.5 0.023033
2.0 0.018737
2.5 0.0132
Peak # 70 —
Strain_Width_Table = 4×1 table
Width_Peak_070
______________
1.0 0.026586
1.5 0.022972
2.0 0.018857
2.5 0.01293
Peak # 71 —
Strain_Width_Table = 4×1 table
Width_Peak_071
______________
1.0 0.05756
1.5 0.023014
2.0 0.018616
2.5 0.013413
Peak # 72 —
Strain_Width_Table = 4×1 table
Width_Peak_072
______________
1.0 0.026508
1.5 0.022972
2.0 0.019149
2.5 0.012914
Peak # 73 —
Strain_Width_Table = 4×1 table
Width_Peak_073
______________
1.0 0.058876
1.5 0.022928
2.0 0.018522
2.5 0.013042
Peak # 74 —
Strain_Width_Table = 4×1 table
Width_Peak_074
______________
1.0 0.026436
1.5 0.022943
2.0 0.019096
2.5 0.012978
Peak # 75 —
Strain_Width_Table = 4×1 table
Width_Peak_075
______________
1.0 0.05791
1.5 0.022988
2.0 0.018567
2.5 0.013084
Cvert = cat(2,Results{:})
Cvert = 4×75 table
Width_Peak_001 Width_Peak_002 Width_Peak_003 Width_Peak_004 Width_Peak_005 Width_Peak_006 Width_Peak_007 Width_Peak_008 Width_Peak_009 Width_Peak_010 Width_Peak_011 Width_Peak_012 Width_Peak_013 Width_Peak_014 Width_Peak_015 Width_Peak_016 Width_Peak_017 Width_Peak_018 Width_Peak_019 Width_Peak_020 Width_Peak_021 Width_Peak_022 Width_Peak_023 Width_Peak_024 Width_Peak_025 Width_Peak_026 Width_Peak_027 Width_Peak_028 Width_Peak_029 Width_Peak_030 Width_Peak_031 Width_Peak_032 Width_Peak_033 Width_Peak_034 Width_Peak_035 Width_Peak_036 Width_Peak_037 Width_Peak_038 Width_Peak_039 Width_Peak_040 Width_Peak_041 Width_Peak_042 Width_Peak_043 Width_Peak_044 Width_Peak_045 Width_Peak_046 Width_Peak_047 Width_Peak_048 Width_Peak_049 Width_Peak_050 Width_Peak_051 Width_Peak_052 Width_Peak_053 Width_Peak_054 Width_Peak_055 Width_Peak_056 Width_Peak_057 Width_Peak_058 Width_Peak_059 Width_Peak_060 Width_Peak_061 Width_Peak_062 Width_Peak_063 Width_Peak_064 Width_Peak_065 Width_Peak_066 Width_Peak_067 Width_Peak_068 Width_Peak_069 Width_Peak_070 Width_Peak_071 Width_Peak_072 Width_Peak_073 Width_Peak_074 Width_Peak_075
______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________ ______________
1.0 0 0 0 0.010448 0.017155 0.019408 0.021816 0.023302 0.029293 0.024837 0.025343 0.038175 0.025784 0.049003 0.025894 0.047299 0.026159 0.026253 0.026347 0.026309 0.053828 0.026216 0.053982 0.026147 0.046402 0.026344 0.026401 0.033576 0.026384 0.056789 0.026319 0.055705 0.026402 0.026549 0.02654 0.026499 0.05361 0.026396 0.056975 0.026321 0.055823 0.026494 0.026577 0.026559 0.026546 0.057305 0.02642 0.057701 0.026367 0.054962 0.026516 0.026601 0.034134 0.026487 0.057889 0.026425 0.057711 0.02644 0.034779 0.02656 0.026517 0.053774 0.026489 0.058565 0.026413 0.058892 0.02653 0.026642 0.026623 0.026586 0.05756 0.026508 0.058876 0.026436 0.05791
1.5 0 0 0 0 0 0 0.012507 0.016398 0.018328 0.019853 0.020683 0.021136 0.021799 0.021748 0.022136 0.02207 0.022393 0.022388 0.022554 0.022531 0.022475 0.022557 0.022413 0.022507 0.022512 0.022654 0.022636 0.022739 0.022684 0.02268 0.022756 0.022677 0.022833 0.022866 0.02293 0.022842 0.022798 0.022818 0.022767 0.022816 0.022785 0.022916 0.022914 0.022944 0.022917 0.022852 0.022845 0.022832 0.022849 0.022898 0.022929 0.022949 0.023019 0.0229 0.022882 0.022902 0.022848 0.022905 0.022963 0.022979 0.022883 0.022976 0.022928 0.02292 0.022923 0.022993 0.022991 0.022999 0.023033 0.022972 0.023014 0.022972 0.022928 0.022943 0.022988
2.0 0 0 0 0 0 0 0 0 0.0068387 0.012244 0.013951 0.015882 0.016204 0.016878 0.017191 0.017339 0.017746 0.017695 0.017821 0.018131 0.01785 0.018155 0.017803 0.018173 0.017911 0.018153 0.018157 0.018144 0.018453 0.01816 0.018701 0.018254 0.018717 0.01845 0.018622 0.018629 0.018367 0.018848 0.018327 0.018932 0.018331 0.018757 0.01858 0.018592 0.018804 0.018452 0.018877 0.01844 0.018906 0.018459 0.018714 0.018675 0.018631 0.018883 0.018475 0.019033 0.018466 0.018898 0.018551 0.018726 0.018678 0.018577 0.01901 0.018489 0.019131 0.01858 0.018937 0.018665 0.018737 0.018857 0.018616 0.019149 0.018522 0.019096 0.018567
2.5 0 0 0 0 0 0 0 0 0 0 0 0 0.0047115 0.0076027 0.0089005 0.0092422 0.0094446 0.01046 0.010671 0.011407 0.010805 0.011586 0.010748 0.011696 0.011257 0.011925 0.011761 0.01183 0.01195 0.011793 0.012394 0.012374 0.01273 0.012696 0.012999 0.012603 0.012806 0.012643 0.012477 0.012709 0.012594 0.012898 0.01282 0.013076 0.012788 0.013005 0.012769 0.012849 0.012835 0.012892 0.013007 0.01286 0.013268 0.012773 0.012993 0.01286 0.012942 0.012934 0.012931 0.013088 0.012788 0.013304 0.012849 0.012948 0.012924 0.013215 0.0131 0.01302 0.0132 0.01293 0.013413 0.012914 0.013042 0.012978 0.013084
% % Create scatter
% plot(X,Y,'DisplayName','Voltage',...
% 'Marker','NONE');
% % Create ylabel
% ylabel('Voltage [V]');
% xlabel('No. of Cycles');
%
%
%
% % Find the Given threshold Voltage
% yline(Strain, 'Color', 'r', 'LineWidth', 1);
function [Width,TW] = interpStrain(X,Y,Strain,k)
Strain = Strain(:);
Xend = numel(X);
for k1 = 1:numel(Strain)
% Q = Strain(k1)
idx = find(diff(sign(Y-Strain(k1))));
if ~isempty(idx)
for k2 = 1:numel(idx)
idxrng = max(1,idx(k2)-1) : min(Xend,idx(k2)+1);
xval(k1,k2) = interp1(Y(idxrng), X(idxrng), Strain(k1));
end
else
xval(k1,:) = [0 0];
end
Width(k1,:) = diff(xval(k1,:));
end
TW = table(Width, 'RowNames',compose('%.1f',Strain), 'VariableNames',{sprintf('Width_Peak_%03d',k)});
end
.
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)