is this question too hard for you guys?
left side are not compatible with the size of the right side.
2 views (last 30 days)
Show older comments
>> A=[-8,5,-2,0;-5,2,1,-2;10,-8,6,-3;3,-2,2,0];
>> b=[-29,-26,25,20];
>> cramer(4)
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in cramer (line 7)
B(:,i) = b;
This is my cramer function:
function cramer(n)
A=[];
b=[];
x=[];
for i=1:n
B=A;
B(:,i) = b;
xi=det(B)/det(A);
x=[x,xi];
end
disp(x)
end
2 Comments
Answers (1)
Adam Danz
on 17 Oct 2020
Your cramer function defines b as
b=[];
The loop within that function tries to store the empty value of b in B(:,i) which is of size [1x1] but b is of size [0,0] because it's empty.
B(:,i) = b;
That's why the error message reads,
Unable to perform assignment because the indices on the left side
are not compatible with the size of the right side.
0 Comments
See Also
Categories
Find more on Matrices and Arrays 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!