Create array with 7500 1s, 5000 2s, 8003s etc.

I'm new to matlab, and I have to create a histogram based off a picture where the values are 7500 1s, 2500 2s, 800 3s and 100 4s. I think if I can get a row array with all those values (Order doesn't matter) I can make the histogram.

3 comentarios

Caleb Lindsey
Caleb Lindsey el 26 de Sept. de 2017
I also need to turn the row vector into a column vector
James Tursa
James Tursa el 26 de Sept. de 2017
Editada: James Tursa el 26 de Sept. de 2017
What have you done so far? What specific problems are you having with your code? Do you know how to construct row or column vectors of constant values? Do you know how to create a histogram?
Hint, to create an N-element row vector with constant value V:
x = V*ones(1,N);
Hint, to turn a row vector into a column vector:
x = your row vector
y = x(:); % <-- y will be a column vector
y = reshape(x,[],1); % <-- another way to get a column vector
Caleb Lindsey
Caleb Lindsey el 27 de Sept. de 2017
x=V*ones(1,N) and y=x(:) were exactly what I needed thank you very much!

Iniciar sesión para comentar.

Respuestas (1)

Categorías

Preguntada:

el 26 de Sept. de 2017

Comentada:

el 27 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by