what changes are needed
1 view (last 30 days)
Show older comments
accG2_A = C(:,1).*9.81;
forceG2_A = C(:,2).*0.00981;
dispG2_A = C(:,3)./1000;
time = dispG2_A./accG2_A;
s = smooth(forceG2_A);
%converted_values = findpeaks(converted_values);
%Force = converted_values(:,2);
plot (s);
how can i used this following data to plot the single cycle and not the following plot.
986 120 0
981 -60 0
984 -60 0
986 -70 0
993 -70 0
997 -70 0
1000 -70 0
1005 -70 0
1005 -70 0
1000 -70 0
994 -60 0
2 Comments
Walter Roberson
on 17 Oct 2021
I have no idea how that data relates to that plot. The data has no value above 1005 (and has duplicate values in the first column). The data has nothing that appears to be in the range 0 to 16-ish. Your third column is all 0, so your time works out all 0.
Answers (2)
Star Strider
on 17 Oct 2021
Try this —
F = openfig('Manav Divekar untitled.fig');
F.Visible = 'off'; % Don't Show Original
Ax = F.CurrentAxes;
x = Ax.Children.XData; % Get 'X'
y = Ax.Children.YData; % Get 'Y'
[Valleys,vlocs] = findpeaks(-y, 'MinPeakProminence',5); % Locate 'Valleys'
vlocs = [1 vlocs]; % Row Vector
Ts = mean(diff(x)); % Sampling Interval
for k = 1:numel(vlocs)-1
pkrng = vlocs(k) : vlocs(k+1); % Peak Rnage (Indices)
xr{k} = x(pkrng); % 'X' Values For Peak
yr{k} = y(pkrng); % 'Y' Values For Peak
end
np = numel(xr); % Number Of Peaks
nrows = 2; % Number Of Rows For Plot
figure
for k = 1:numel(xr)
subplot(nrows,fix(np/nrows),k)
plot(xr{k}, yr{k})
grid
title(sprintf('Peak #%d',k))
end
np = numel(xr);
maxx = max(cellfun(@numel,xr)); % Maximum Segment Length
ensemble = zeros(np,maxx); % Preallocate
for k = 1:np
ensemble(k,1:numel(yr{k})) = yr{k}; % Accumulate 'Y' Values For Each Peak
end
ensmean = mean(ensemble); % Calculate Ensemble Mean
ensstd = std(ensemble); % Ensemble Standard Deviation
enssem = ensstd/sqrt(np); % Ensemble Standard Error
tval = tinv([0.025 0.975],np-1); % t-Statistic For Confidence Intervals
figure
plot((1:maxx)*Ts, ensmean)
hold on
plot((1:maxx)*Ts, ensmean+tval(:)*enssem, ':k')
hold off
grid
xlabel('x')
ylabel('y')
title('Ensemble')
legend('Mean', '± 95% CI', 'Location','best')
Esperiment to get different results.
.
4 Comments
Star Strider
on 17 Oct 2021
I did not see that you replaced the .fig file (originally) with a .txt file. (I have no idea when that occured.) The text file would have been easier for me to work with.
Nevertheless, I provided the requested information, including plots of the original peaks (choose which of them to plot if you only want to plot one) and an ensemble average of all of them, with relevant statisitics.
If my Answer helped you solve your problem, please Accept it!
.
Walter Roberson
on 17 Oct 2021
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/769961/G2_A.txt';
C = readmatrix(filename);
forceG2_A = C(:,2).*0.00981;
s = smooth(forceG2_A);
plot(s)
[~, idx] = findpeaks(s, 'MinPeakHeight', 6);
mid = floor(idx(1:end-1) + diff(idx)/2);
t1 = 1:mid(1);
s1 = s(t1);
t2 = mid(1)+1:mid(2);
s2 = s(t2);
plot(t1, s1, 'k*-', t2, s2, 'b+-')
0 Comments
See Also
Categories
Find more on Manage System Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!