Borrar filtros
Borrar filtros

formal initialisation of matrix

2 visualizaciones (últimos 30 días)
Julien
Julien el 9 de Abr. de 2014
Respondida: Julien el 10 de Abr. de 2014
Hi,
I would like to know if it's possible to create a matrix A by giving the value of every coefficient A(i,j). Something like that :
A(i,j) = i+j
I would like to do this directly when the matrix is created, not using the double for i, for j.
Thankyou for your answer,

Respuesta aceptada

lvn
lvn el 10 de Abr. de 2014
Answering your second question
A=bsxfun(@eq,x,y');

Más respuestas (4)

Titus Edelhofer
Titus Edelhofer el 9 de Abr. de 2014
Hi Julien,
often you can use the function meshgrid for this...
Titus

lvn
lvn el 9 de Abr. de 2014
Three alternative solutions posted here:

Julien
Julien el 9 de Abr. de 2014
Thankyou for your rapid answer, it helps me a lot =)
Now if it's possible, I would like to construct a matrix of booleans based on the same idea but with :
A ( i , j ) = ( x(i) == y(j) )
with x and y known vector.
If somebody has idea..
Thanks a lot,

Julien
Julien el 10 de Abr. de 2014
Perfect answer thankyou it's okay =)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by