MATLAB: The Value assigned to variable ‘C’ might be unused?

linsolveMATLABmatrix

Hi, I am struggling with a piece of code listed below: I am getting the error 'The Value assigned to variable 'C' might be unused' next to the first 'C' equation below Is there any solution. Thank you.
A= [0; 0; 10];
B= [5 -2 0; -3 2 -1; 0 0 1];
C= [I3; I2; I1];
C= linsolve(B,A)

Best Answer

You create a C matrix by vertically concatenating three matrices/vectors on your first C equation. On the next line, you create a new C matrix by calling linsolve, effectively discarding the C you created on the previous line.
That's what matlab is telling you: you create a C, never use it, and replace it with something else. The solution to your problem depends on your intent. If you did want to use the first C then use a different variable name for the output of linsolve. If you never intended to use that first C, then don't create it.
As a side note, use better variable names anyway, A, B, C, I1, I2, etc. do not tell me anything about the purpose of the variables. Names like numberofpeople, walltemperature, signalfrequency, etc. do.