Creating certain amount of new rows from each row in a matrix?

1 visualización (últimos 30 días)
How can I create certain amount of rows from each row? For example
A=[a b c d
Then I want to create n new rows from the first row, and m new rows from the second and third row.
e f g h
i j k l]
from [a b c d] => Let n=2 =>
New rows [x y z k
t y j m]
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 18 de Mayo de 2016
How x,y,... are related to a,b,...?
CarenCaren
CarenCaren el 18 de Mayo de 2016
New_one = firstrow ± (rand()/intensity) × firstrow
New_one = secondrow ± rand() × secondrow

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Mayo de 2016
[repmat(A(1,:), n, 1);
repmat(A(2:end,:), m, 1)]
  2 comentarios
Walter Roberson
Walter Roberson el 18 de Mayo de 2016
A1_n = repmat(A(1,:), n, 1);
A2_m = repmat(A(2,:), m, 1);
A3_m = repmat(A(3,:), m, 1);
Acol = size(A,2);
result = [A1_n + repmat((rand(n,1) * 2 - 1) / intensity, 1, Acol) .* A1_n;
A2_m + repmat(rand(m, 1) * 2 - 1, 1, Acol) .* A2_m;
A3_m + repmat(rand(m, 1) * 2 - 1, 1, Acol) .* A3_m];

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by