c1 = ult_trid(m,b);
In your main function, that is the first time you mention c1, and it is an output from ult_trid .
function c1 = ult_trid(m,b)
Okay, within function ult_trid, the inputs are m and b, and the output is c1.
n = length(b);
c1(n) = c1(n)/m(n);
c1 does not exist yet on the right hand side of that assignment. And since we just went through the calling sequence, we know that c1 is not being passed into the function. We also looked at the place that the function was called and have established that c1 does not exist before the function is called, so there is no c1 to pass into the function.
c1(n) = c1(n)/m(n);
for j=2:n
c1(j) = c1(j) - m(j)*c1(j);
end
You process c1(n) twice, once explicitly by itself, and the second time when j = n. Meanwhile you never process c1(1) . Are you sure this is wise?
You do not document your functions, so we cannot tell what your intention is in creating and using c1.
As you do not document any "pre-conditions", as outside observers, we must expect that you have accidentally forgotten to check for the possibility that m(n) is 0.
I suspect your code would be a lot easier to write if you used a 2D matrix instead of holding each column as an independent variable.