Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-4.

1 view (last 30 days)
a=[1 1 3;2 0 2;1 1 0;];
b=[5;6;7]
ab=[a b]
%pivot 1,1
%
if ab(1,1)< abs(max(ab(:,1)))
piv=ab(1,:)
ab(1,:)=ab(2,:)
ab(2,:)=piv
ab(2,1)=ab(2,:)-ab(2,1)/ab(1,1)*ab(1,:)
ab(3,1)=ab(3,:)-ab(2,1)/ab(1,1)*ab(1,:)
end

Accepted Answer

Walter Roberson
Walter Roberson on 11 Sep 2021
ab(2,1)=ab(2,:)-ab(2,1)/ab(1,1)*ab(1,:)
ab(2,1) is a scalar and ab(1,1) is a scalar, so ab(2,1)/ab(1,1) is a scalar. So at the end of the expression, you are multiplying the vector ab(1,:) by a scalar, getting back a vector.
ab(2,:) is a vector.
You are subtracting a vector from a vector, which is an operation that returns a vector.
So the right hand side is a vector.
The destination ab(2,1) is, however, a scalar location. You cannot store a vector into a scalar location.

More Answers (0)

Categories

Find more on Propagation and Channel Models 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!