How do I get each iteration of a for loop into a single row matrix?
Mostrar comentarios más antiguos
Here I am getting each iteration correctly but I need pmf to be a row matrix with the answers from 0 to max(Data).
function [pmf] = CalcRelFreq(Data);
for range = 0:max(Data)
pmf = [1 ;sum(Data == range)/length(Data)]
end
2 comentarios
James Tursa
el 24 de Abr. de 2025
Editada: James Tursa
el 24 de Abr. de 2025
What is size(Data)? Please provide a small example input and desired output. pmf looks like a column vector, so it is unclear how you want these stacked into a row vector.
Respuestas (1)
Data=[ 11
17
13
4
12
8
12
10
7
14
12
6
10
14
11
10
10
9
10
13];
pmf=histcounts(Data,0:max(Data)+1)'/length(Data),
Categorías
Más información sobre Univariate Discrete Distributions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!