pointwise multiplication of sparse matrix with full array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sandra Martinez
el 12 de Dic. de 2022
Comentada: Sandra Martinez
el 13 de Dic. de 2022
How can I do this operation?
A=sparse([1 0;0 0]);
B=rand(2,2,2,2);
C=A.*B;
the only way is converting B into a sparse array with this function?
remark: A is sparse but B is not.
0 comentarios
Respuesta aceptada
Torsten
el 12 de Dic. de 2022
Editada: Torsten
el 12 de Dic. de 2022
rand(2,2,2,2) generates a (2x2x2x2) array for B. You cannot multiply A with such a B elementwise because the array sizes don't match.
A=sparse([1 0;0 0]);
B=rand(2,2);
C=A.*B
Or what do you expect as result for B being (2x2x2x2) ?
Más respuestas (1)
Ver también
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!