Removing unwanted data from a Histogram
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
pratapaneni Chetan
le 23 Sep 2021
Commenté : pratapaneni Chetan
le 24 Sep 2021
In the given histogram below, I want to remove all the data thats below 4000 on the Y axis. How can this be done?
Thanks in advance :)
0 commentaires
Réponse acceptée
Image Analyst
le 24 Sep 2021
Here is a full demo. Attach your data or histogram if you need more help.
% Demo by Image Analyst.
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
% str = "MathWorks was founded in 198.4. Patterns were 1st introduced in R2020b.";
% pat = digitsPattern;
% % pat = lettersPattern;
% year = extract(str,pat)
data = 10 + 5 * randn(1000000, 1);
subplot(2, 1, 1)
counts = histcounts(data); % Get histogram.
bar(counts, 1);
grid on;
title('Original -- All Bins', 'FontSize', fontSize);
xlabel('Value', 'FontSize', fontSize);
ylabel('Counts', 'FontSize', fontSize);
yline(4000, 'Color', 'r', 'LineWidth', 2);
indexes = counts < 4000; % Find out what bins have less than 4000 counts.
counts(indexes) = 0; % Set those bins to zero.
subplot(2, 1, 2)
bar(counts, 1);
grid on;
title('Now With Bins Below 4000 Zeroed Out', 'FontSize', fontSize);
xlabel('Value', 'FontSize', fontSize);
ylabel('Counts', 'FontSize', fontSize);
yline(4000, 'Color', 'r', 'LineWidth', 2);
fprintf('Done running %s.m\n', mfilename);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!