I only want 1/4 of the data for one of my lines on my graph
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I don't have a lot of Matlab experience, but I was given a code that has two different sets of data, at to different sample rates. The instron data is taken at a rate of 20 points per second and the sensor data is taken at a rate of 80 points per second. I want to only take 1/4 of the sensor data so that the rates of both data sets match up, how would I do this ? anything helps !
% Import the data
for k=1:size(files)
TestSensor = readtable(files(k,1),opts);
TestInstron = readtable(files(k,2),opts_instron);
% transfer the table data to the array
sensor_data = table2array(TestSensor(2:height(TestSensor)-2,:));
instron_data = table2array(TestInstron(2:height(TestInstron),:));
% Plotting
%Pulling Force
plot(sensor_data_shift.*mask,sensor_data(:,3).*mask,'LineWidth',1.5,'Color',[0.267, 0.447, 0.769])% RGB Blue 68, 114, 196
hold on
%Normal Force
plot(instron_data(:,1)/SampleRate+gap,instron_data(:,3),'LineWidth',1.5,'Color',[0.929, 0.490, 0.192])% RGB Orange 237, 125, 49
%Friction
% RGB Grey 165, 165, 165
legend('Normal Force','Pulling Force','Friction*1000')
grid on
title(NamedGraphTitle)
xlabel('Time(s)')
ylabel('Force (lbs)')
axis([16.5,TimeendX,0,7500])
hold off
end
댓글 수: 0
답변 (1개)
ILoveMATLAB
2022년 6월 23일
편집: ILoveMATLAB
2022년 6월 30일
You should be able to do this using logical indexing. Please see the code below.
numOfRepetitions = round(length(instron_data )/ 4);
tfKeep = repmat([true false false false]', [numOfRepetitions,1]); % You may want [ false false false true]
tfKeep = tfkeep(1:length(instron_data),:);%Just in case the logical the array is too long
new_instron_data = instron_data(tfkeep,:)
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!