randomly inserting element in 2d matrix

14 Ansichten (letzte 30 Tage)
mukesh gupta
mukesh gupta am 16 Mär. 2017
Kommentiert: Jan am 16 Mär. 2017
let there is 2 2d matrix A=[1,2;3,1] and B=[5,6;7,8] required output is C=[5,8;0,6;0,7] my code but its not that correct
for i=1:2
for j=1:2
C(A(i,j),end+1)=[B(i,j)];
end
end
is there any correct sloution where i can insert elements, in random rows of 2d matrix.
  2 Kommentare
ES
ES am 16 Mär. 2017
Your question is not clear. You want to create a matrix C "randomly" with elements from A and B? Try perms, nchoosek, randperm, permute, combvec
Jan
Jan am 16 Mär. 2017
I don't get it. Please explain the procedure to create the output.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by