Is there any way to do broadcasting while assigning values to an array?
I know how to broadcast a computation:
ans =
1 2 3
1 2 3
1 2 3
But I want to assign the above values to G directly:
Unable to perform assignment because the size of the left side is 3-by-3 and the size of the right side is 1-by-3.
I know how to broadcast a simple scalar value:
G =
1 1 1
1 1 1
1 1 1
And I realise I could do this instead:
G(:,:) = repmat([1 2 3], 3, 1)
G =
1 2 3
1 2 3
1 2 3
But I wondered if there is a simpler way to assign a vector of values to all the rows using automatic broadcasting.
Judging by the answers to this question, I am guess not, but I wanted to check.