Borrar filtros
Borrar filtros

Appending Arrays at the END!

1 visualización (últimos 30 días)
Sanchit Sharma
Sanchit Sharma el 12 de Dic. de 2018
Comentada: Sanchit Sharma el 13 de Dic. de 2018
I have three arrays of sizes:
1) A[]=839063*1; (ZEROS)
2) B[]=4393*1; (some values) {example [0.1 0.2 0.3 . . . . ] random values }
3) C[]=191*1; (some values randomized)
Here I need to multiply every element of C[] with EACH element of B[]. like
for i= 1:length(B)
ANS = B(i) * C; { example 0.1 * [1 2 3 4 5 6 7 8 9 . . . . . 191] like this I have to do 4393 times}
END
Then I have to store all these values in array A[] and I have to append these values at the end of the array after each for loop.
Currently I am using the below algorithm to resolve this, and is not working. Can you please tell me a better way to do this????
for i = 1:length(A)
for j = 1:length(B)
for k = 1:191
A(i)=B(j)*C(k);
end
end
i=i*(191);
end

Respuesta aceptada

James Tursa
James Tursa el 12 de Dic. de 2018
Editada: James Tursa el 12 de Dic. de 2018
E.g.,
A = B * C.'; % outer product
A = A(:); % turn into column vector
  9 comentarios
madhan ravi
madhan ravi el 13 de Dic. de 2018
+1 , it works !
Sanchit Sharma
Sanchit Sharma el 13 de Dic. de 2018
I got it Thanks a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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