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')

 채택된 답변

Roger Stafford
Roger Stafford 2014년 11월 30일

0 개 추천

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.

댓글 수: 2

I changed it to this:
t=[5*60:60:60*60];
for k=1:length(t)
tau(k)=((t*a)/r^2);
Tc(k)=(Ts+((Ti-Ts)*(A*exp(l^2*(-tau)))))
Q(k)=(Qmax*(1-(2*((Tc-Ts)/(Ti-Ts))*(J/l))))
end
but now it gives me this error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in HT461 (line 28) tau(k)=((t*a)/r^2);
Patricia
Patricia 2014년 11월 30일
I figured it out! thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Patricia
Patricia 2014년 11월 30일

0 개 추천

I changed it to this:
t=[5*60:60:60*60];
for k=1:length(t)
tau(k)=((t*a)/r^2);
Tc(k)=(Ts+((Ti-Ts)*(A*exp(l^2*(-tau)))))
Q(k)=(Qmax*(1-(2*((Tc-Ts)/(Ti-Ts))*(J/l))))
end
but now it gives me this error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in HT461 (line 28) tau(k)=((t*a)/r^2);

댓글 수: 1

Star Strider
Star Strider 2014년 11월 30일
See if subscripting ‘t’ as ‘t(k)’ corrects that.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

질문:

2014년 11월 30일

댓글:

2014년 11월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by