Hi, I am trying to plot the temperature along a 1D length scale using finite element method on nodes, i.e. the temperature of node i-1 is the boundary condition for node i-1. fzero worked to give the first value before I introduced the for loop. The error 'Index exceeds matrix dimensions' appeared when I started using the for loop. Is there anyway to fix this?
%constants:
h=6.47; Lc=0.0168; %distance between nodes
L=1.274; %total length
Ta=20+273; Tb=38+273; As=pi*0.0418^2; dt=10; Q=-10; X=0:L/Lc; x=length(X); T=zeros(x); T(1)=39+273.15; %initial condition
for i=2:1:x fcn=@(T) 0.39*As*(T(i)-T(i-1))/Lc+2*pi*0.0418*Lc*(h*(T(i)-Ta)+0.99*5.67e-8*(T(i).^4-Ta^4))+As*Lc*1069*3650*3.28e-4*(Tb-T(i))+398*As*Lc+398*(2.^(0.1*(T(i)-303.35))-1)*As*Lc-3057*As*Lc*1052*(T(i)-T(i-1))/dt+Q; T=fzero(fcn,T(i-1)); <--Error: Index exceeds matrix dimensions end
Thank you very much!
Best Answer