MATLAB: How to code for an equation for numbers of input

matlab function

Hi,
I am new in Matlab.
Would like to know how to code for this problem.
I have this equation
Qc = 2*N*((alpha*I0*Tc)-(0.5*I0*I0*(rho/G))-(k*G*(Th-Tc)))
And i want to compute this equation for I0 from 1 to 10 and Tc from -60 to 240.
I try coding it this way.
//
N= 96;
G = 0.072;
alpha = 0.000203;
rho = 0.001095;
k = 0.01438;
Th = 323;
for I0 = 0.0
for Tc = -60.0
Qc = 2*N*((alpha*I0*Tc)-(0.5*I0*I0*(rho/G))-(k*G*(Th-Tc)))
I0 = I0+1
Tc = Qc+30
if I0>=11 && Tc >=270
end
end
end
But, it only give me 1 answer instead of I need the Qc to give me the output in terms of I(1:10) and Tc (-60:240)
Please help

Best Answer

N = 96;
G = 0.072;
alpha = 0.000203;
rho = 0.001095;
k = 0.01438;
Th = 323;
[I0, Tc] = ndgrid(1:10, -60:240);
Qc = 2*N*((alpha .* I0 .* Tc) - (0.5 .* I0 .* I0 .* (rho./G)) - (k .* G .* (Th-Tc)));
surf(I0, Tc, Qc, 'edgecolor', 'none')