how can I get the following graph from this data, changes are required in the code
Mostrar comentarios más antiguos
clc
clear all
close all
% Lab 2 Group G2 Data Analysis
%[files,path] = uigetfile({'.txt'},'MultiSelect', 'on');
%if iscell(files)
% for n = 1:length(files)
% data = importdata(fullfile(path,files{n})); % fullfile including path
% save data
%end
%else
% data = importdata(fullfile(path,files));
% save data
%end
%G2test = importdata('G2_A.txt','G2_C.txt');
%fid= fopen('G2_A.txt');
%C= readmatrix('data', 'NumHeaderLines',8);
C= readmatrix('G2_A.txt', 'NumHeaderLines',8);
dG2test = C(:,3);
for i = 1:length(dG2test)
if dG2test(i)<0
dG2test(i) = dG2test
end
end
%Convert to SI Units
accG2test = C(:,1).*9.81;
forceG2test = C(:,2).*0.00981;
dispG2test = C(:,3)./1000;
time = dispG2test./accG2test;
s = smooth(forceG2test);
%Find the peak and plot
[~, idx] = findpeaks(s, MinPeakHeigh = 6);
%minAdult = islocalmin(s);
%minLocs = find(minAdult ==1);
%for j = 1:11
%for k = 5:16-1
% newdata{j,:} = dataAdult(minLocs(k):minLocs(k+1),:);
% newdataAdult{minLocs(1):(minLocs(k+1)-minLocs(k)),:} = newdata;
%end
%end
mid = floor(idx(1:end-1) + diff(idx)/2);
t1 = 1:mid(1);
s1 = s(t1);
%t2 = 1:mid(6);
%s2 = s(t2);
plot(t1,s1);
hold on

Please Refer the attached .txt file for the data
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Exploration and Visualization en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

