Why the MATLAB auto converts variable into Matrix?

The following code generates (3x1) Matrix of Profit variable. How to get a single answer (value) from the Profit function?

for j =1:56
      b = 20  ;
      c1 =  30 ;
      Qt = 100;

      Profit =  (- (Qt^2*(b - c1))/(b + c1)^3 - (Qt*c1*l1)/(b + c1)^2 - (2*Qt^2*b*c1*l2)/(b + c1)^3);

end for 

The above code output the following answer:

Profit =


 -6.1929
 -6.1926
 -6.1924

1 answer

  • answered 2018-07-11 02:54 jehan

    Problem resolved.

    l2 and l1 in the program was 3x1 matrix. This why I was getting 3x1 as the answer.