Matrix replications and form third matrix

1 Ansicht (letzte 30 Tage)
Algorithms Analyst
Algorithms Analyst am 25 Feb. 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 Kommentare
Matt J
Matt J am 25 Feb. 2013
Bearbeitet: Matt J am 25 Feb. 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 am 26 Feb. 2013
I am sorry it is my mistake.......it is 114*40

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Thorsten
Thorsten am 25 Feb. 2013
A = rand(144, 400);
B = rand(144, 1600);
A(size(B, 1), size(B, 2)) = 0;
D = A.^2 + B.^2;
size(D)

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