Assign the same variable to all elements of a Matrix
13 views (last 30 days)
Show older comments
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 Comments
Answers (2)
John D'Errico
on 8 Nov 2021
As with Matt, I have not used the code, but this should work.
M = repmat(sdpvar(1,1),[10 10 10]);
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!