Matrix replications and form third matrix

2 vues (au cours des 30 derniers jours)
Algorithms Analyst
Algorithms Analyst le 25 Fév 2013
Hi everyone
I have two matrices A with size of (144x40) and B with same size.What I am trying to do is actually I want to take the square of them and add to form another matrix which is just a row or column with size of 1600.
A=144x400 B=144x1600.
D=A.^2+B.^2 .
So this D must be a column or row matrix with size of 1600x1 or 1x1600.
I have made a function
function D = repc(in,M,N)
D = in(repmat(1:size(in,1),M,1),repmat(1:size(in,2),N,1));
end
But when I compute A its size becomes double 20736x1600 and I cannot compute B because of out of memmory error
  2 commentaires
Matt J
Matt J le 25 Fév 2013
Modifié(e) : Matt J le 25 Fév 2013
Initially, you said that both A and B are 144x40. Later in your post, both matrices change size, to 144x400 for A and 144x1600 for B. In neither case is it clear what operation you would do to produce a length 1600 vector.
Please rephrase more clearly and with consistent information about size(A) and size(B).
Algorithms Analyst
Algorithms Analyst le 26 Fév 2013
I am sorry it is my mistake.......it is 114*40

Connectez-vous pour commenter.

Réponses (1)

Thorsten
Thorsten le 25 Fév 2013
A = rand(144, 400);
B = rand(144, 1600);
A(size(B, 1), size(B, 2)) = 0;
D = A.^2 + B.^2;
size(D)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by