how to create a histogram for featim?

1 次查看(过去 30 天)
hi matlab community, is something wrong with my coding below? i want to create a histogram for featim. thnkyou so much.
feat=zeros(982,40);
for k=1:982
A=FYPdatabase{k,1};
featim=gmlog(A);
FYPdatabase{k,5}=featim;
end
hist3(featim);

回答(1 个)

Abhinaya Kennedy
Abhinaya Kennedy 2024-8-20
Here are some points to consider:
  1. Variable Scope: featim is being overwritten in each iteration of the loop. If you want to create a histogram of featim after the loop, you should accumulate the data across iterations.
  2. Data Dimensionality: hist3 is used for 2D histograms. If featim is a 1D array, you should use histogram instead (https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram.html) .
  3. Data Storage: Ensure that gmlog(A) returns data in a format suitable for a histogram (e.g., a 1D array).
feat = zeros(982, 40); % Assuming 40 is the length of feature vector
allFeatim = []; % To accumulate all featim data
for k = 1:982
A = FYPdatabase{k, 1};
featim = gmlog(A);
FYPdatabase{k, 5} = featim;
% Assuming featim is a vector, accumulate it
allFeatim = [allFeatim; featim(:)]; % Concatenate featim into a single column
end
% Create a histogram for all accumulated featim data
histogram(allFeatim);
xlabel('Feature Value');
ylabel('Frequency');
title('Histogram of Feature Values');
allFeatim = [allFeatim; featim(:)] ensures that all feature values are stored in a single column vector, suitable for histogram plotting. Adjust the code further based on the specific output format of gmlog(A).

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by