How can I combine a frequency array and a value array?

1 visualizzazione (ultimi 30 giorni)
How can I combine a frequency array and a value array in MATLAB? I have one array that contains values: A=[1 2 3 4 5] And one array that shows the frequency of these values: F=[23 19 34 26 21] How do I combine these into one array?

Risposte (1)

Guillaume
Guillaume il 28 Feb 2015
It's not clear what you're asking. Maybe this?
A=[1 2 3 4 5];
F=[23 19 34 26 21];
cell2mat(arrayfun(@(a, f) repmat(a, [1 f]), A, F, 'UniformOutput', false))

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by