Finding the max value out of 1000 sample set at every second.
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a data set collected time versus strain. Strain data is collected at multiple points. So, I have one column for the X-axis and multiple columns for the Y-axis.
The sample data is collected 1000 times every second. I want to get the maximum value for strain at every second (out of 1000 samples) and plot it against the time. The test runs for 4 hours, so I want to convert the time from seconds to hours.
So, there will be multiple lines for the Y-axis in the plot.
I am looking forward to any help.
Thanks
2 个评论
VBBV
2021-10-27
for i = 1:10
xy(:,i) = unidrnd(1000,1000*60*60,1); % strain data
end
T =1:length(xy)/1000; % time data
[V I] = max(xy(1:1000:end,:))
plot(T(I),V)
Try this
回答(1 个)
Pranjal Kaura
2021-10-29
Hey Kawalpreet,
You can refer to the following code snippet wherein I've tried to replicate your usecase and provided a solution.
sample_rate = 10; %1000 for you
num_rows = 1000; %1 million for you
pd = makedist('Normal');
VarName3 = random(pd, [num_rows, 1]);
VarName4 = random(pd, [num_rows, 1]);
dataset = [VarName3 VarName4];
dataset_sampled = reshape(dataset, sample_rate, num_rows/sample_rate, size(dataset, 2));
dataset_sampled_max = squeeze(max(dataset_sampled, [], 1));
time_sec = 1:length(dataset_sampled_max);
time_hours = time_sec/3600;
plot(time_hours, dataset_sampled_max);
xlabel("Time in Hours");
You can refer to the 'plot' documentation to know more about addings labels, legends, color etc to the plot.
Hope this helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!