Borrar filtros
Borrar filtros

How can I create the following vector??

2 visualizaciones (últimos 30 días)
OSCAR ZAMORA PICAZO
OSCAR ZAMORA PICAZO el 19 de Mayo de 2016
Comentada: Guillaume el 19 de Mayo de 2016
I have a vector called "y", which is for plotting values in the y axis. Also, I have a variable which is a scalar number, but I want to create a vector with the number of places of "y", but having all values of this vector the same value of that variable.
As an example: y = 0:0.5:3;
r = 30
r' = [30 30 30 30 30 30]
The thing is that my vector "y" is much longer than that.
So, how can I create the vector called "r'"?

Respuestas (1)

Adam
Adam el 19 de Mayo de 2016
Editada: Adam el 19 de Mayo de 2016
r = repmat( 30, [numel(y), 1] );
or
r = 30 * ones( numel(y), 1 );
or
r = 30 + zeros( numel(y), 1 ) );
I haven't tested which is more efficient.

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by