How to Extract 2048 values containing the maximum value?
Show older comments
Hi,
I have a file with total of 49,152 x1 values. I want to split them into ranges of 2048 values and extract the 2048 values that has the maximum number so I can plot the largest 2048 values. This is the code I have right now:
plot(A(1:2048))
hold on
for i = 1:(numel(A)/2048)-1
data_segment = A(1+2048*i: 2048*(i+1));
z{i}=sum(data_segment);
z=z';
plot(data_segment)
end
hold off
xlim([1,2048])
%%ivMax=index of max
[Vmax,ivMax]=max(A)
L=data_segment(ivMax/2048)
Vmax gives me the maximum value and ivMax tells me the index of where to find that value. I set L to find which set of 2048 values to find the max and got ~21. How can I extract the 21st 2048 values? Is there any easier way to do this?
Accepted Answer
More Answers (1)
"I want to plot only the largest 2048 values"
A = readmatrix('Data2048.txt');
A = sort(A,'descend');
plot(A(1:2048))
Categories
Find more on Discrete Data Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
