# creating a matrix of zeros of size of another matrice

106 Ansichten (letzte 30 Tage)
Kommentiert: farzad am 11 Nov. 2014
I have code , in which a matrice r as 1*100 matrice.
then It makes make
pp=zeros(1,size(r,2));
I don't know what 2 means , I know that 1 means the number of rows , but only 2 works in this comment
what is it ?
thank you
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
per isakson am 11 Nov. 2014
Answer to the question in the subject line:
B = zeros( size(A) );
and see the documentation on size.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Mikhail am 11 Nov. 2014
Bearbeitet: Mikhail am 11 Nov. 2014
So zeros(a1,a2) creates a matrix of zeros with a1 rows and a2 columns, for example:
a=zeros(2,3)
is
a=0 0 0
0 0 0
So code pp=zeros(1,size(r,2)); will create matrix pp with 1 row and size(r,2) columns. As long as size(r,2 ) is the number of columns of matrix r, size of pp will be equal to size of r.
Size(r,1) is number of rows in matrix r
Size(r,2) is number of columns
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
great thanks a lot

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Multidimensional Arrays 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