Assign the same variable to all elements of a Matrix
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to assign a variable to all elements of a Matrix without using a for loop to obtain a matrix M such that : M(nxn) = [x , x, x , x ,x ... ].
In my particular case x is an sdpvar and M is a matrix I use to set up the constraints of an optimisation problem.
Thank you
0 comentarios
Respuestas (2)
John D'Errico
el 8 de Nov. de 2021
As with Matt, I have not used the code, but this should work.
M = repmat(sdpvar(1,1),[10 10 10]);
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices 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!