MATLAB: How to plot values of a for loop

for loopplot

Hey guys, when I run this code I get an output with every value for Tc and Q. But these values won't plot, I just get a blank plot with no dots or lines. I have tried using both plot and plotyy, none of them work. Please help me.
%Given values:
d=0.35; % (m)
k=14.9; % (W/m.K)
r=d/2;
ro=7900; % (kg/m^3)
cp=0.477; % (kJ/kg.K)
a=3.95*10^-6; % (m^2/s)
Ti=400+273; % (K)
h=60; % (W/m^2.K)
Ts=150+273; % (K)
%Finding biot number:
Bi=(h*r/k);
%Values obtained from table:
l=1.0935; %lambda
A=1.1558;
J=0.4689;
%Finding Qmax:
m=ro*pi*r^2*1;
Qmax=m*cp*(Ti-Ts);
Tc=0;
Q=0;
%Generating temperature and heat transfer numbers
for t=5*60:60:60*60
tau=((t*a)/r^2);
Tc=(Ts+((Ti-Ts)*(A*exp(l^2*(-tau)))))
Q=(Qmax*(1-(2*((Tc-Ts)/(Ti-Ts))*(J/l))))
end
t=[5*60:60:60*60];
%ploting values
[hAx,hLine1,hLine2] = plotyy(t,Tc,t,Q)
xlabel('Time (s)')
ylabel(hAx(1),'Center temperature (K)')
ylabel(hAx(2),'Heat transfer (kJ)')
title('Center temperature and heat transfer as a function of time')

Best Answer

In your for loop you are not placing the successive values of Tc and Q in vectors. Instead they are being overwritten so that only the last pair is available for plotting. Change to:
t=5*60:60:60*60;
for k = 1:length(t);
tau = ...
Tc(k) = ...
Q(k) = ...
etc.