MATLAB: Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use ‘.^’.

for loopMATLAB

I am trying to find the positive root of this equation and plot it against a variable h. I keep getting NaN for all my answers in my array. Any help is appreciated. Here is the source thus far:
alpha = 0.8;
G = 2000;
emissivity = 0.5;
BoltzmannC = power(5.67,-8);
T = 0;
%valuesofT = zeros(1,200);
for h = 1:200
T = (G.*alpha) - h.*(T - T_infinity) - emissivity.*BoltzmannC.*(power(T,4) -power(T_surr,4))
plot(T)
end

Best Answer

No need for loop
alpha = 0.8;
G = 2000;
emissivity = 0.5;
BoltzmannC =(5.67.^-8);
T = 0; %valuesofT = zero(1,200);
T_infinity = 25
T_surr = 5
h = 1:200
T = (G*alpha) - h.*(T-T_infinity) - emissivity*BoltzmannC*(T^4)-(T_surr^4)
plot(h,T)
Note: I gave an arbitrary constant for T_surr and for plot I just plotted h vs T.
Related Question