how to create a histogram for featim?

1 visualización (últimos 30 días)
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN el 14 de Jun. de 2023
Respondida: Abhinaya Kennedy el 20 de Ag. de 2024
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);

Respuestas (1)

Abhinaya Kennedy
Abhinaya Kennedy el 20 de Ag. de 2024
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).

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by