All variables are defined: mcphayphayvz, betaz, xiz, QH, deltaQH, M1, gammar, mcphayvc, Tc. I want MATLAB to solve z for Tz
if true % clear a b c Tz
z = @(Tz) Tz*mcphayphayvz.*betaz-((xiz*(QH - deltaQH))./(M1(1+gammar)))-(mcphayvc.*Tc); a = -1000; b = 10000; if z(a)*z(b)>0; fprintf('No roots exist within the given interval\n'); return; end; if z(a)==0; fprint('a is one of the roots'); return; elseif z(b)==0; fprint('b is one of the roots'); return; end; for i = 1:10000; c=(a+b)/2; if z(a).*z(c2)<0; b=c; else; a=c; end; if abs(z(a))<1.0E-6; break; end; %fprintf('The root: %f\nThe number of the bisections: %d\n', a, i);
end; Tz = a end
Best Answer
Insufficient code to for us to be absolutely certain, but likely:
in that code, your M1 is probably an array instead of a function, and gammar is probably not a non-negative integer such that 1+gammar is a positive integer.
Chances are high that you want