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

回答(1 个)

ILoveMATLAB
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 CenterFile Exchange 中查找有关 Bar Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by