not enough input arguments

4 views (last 30 days)
vinod kumar
vinod kumar on 7 May 2014
Commented: vinod kumar on 9 May 2014
hiii, i m new to matlab and i am trying to execute a function named tempmatrix.m ,, but it is giving error not enough input arguments. the input argument values are coming from the output of other functions which are giving exactly desired results...please help me
error in 11th line...
function [ temp ] = tempmatrix( x, y, z, new, north, south, top, bottom, right, radiation )
T0=27;
temp=T0*ones(101*11,101);
row=101;
col=101;
surface=11;
for cz=1:surface % for the surfaces
for cy=1:row % for the rows
index1=(cz-1)*row*col+(cy-1)*col+1;
index2=(cz-1)*row*col+cy*col;
new1=new(index1:index2,:); *here it is giving error*
top1=top(index1:index2,1);
bottom1=bottom(index1:index2,1);
north1=north(index1:index2,1);
south1=south(index1:index2,1);
right1=right(index1:index2,1);
radiation1=zeros(length(index1:index2),1);
for cx=1:col % for the columns
if cz==1
radiation1(1:col,1)=radiation(((cy-1)*col+1):(cy*col),1).*(temp(cy,cx)^4) ;
radiation1(cx,1)=radiation((cy-1)*col+cx,1)*(temp(cy,cx)^4) ;
end
if cz>1
top1(cx,1)=top1(cx,1)*temp((cz-2)*row+cy,cx);
end
if cz<surface
bottom1(cx,1)=bottom1(cx,1)*temp(cz*row+cy,cx);
end
if cy>1
north1(cx,1)=north1(cx,1)*temp((cz-1)*row+cy-1,cx);
end
if cy<row
south1(cx,1)=south1(cx,1)*temp((cz-1)*row+cy+1,cx);
end
end
if cz==1
right1(1:col,1)=right1(1:col,1)+radiation1(1:col,1);
end
right1(1:col,1)=right1(1:col,1)+north1(1:col,1)+south1(1:col,1)+top1(1:col,1)+bottom1(1:col,1);
for i=1:col-1;
new1(i,3)=new1(i,3)/new1(i,2);
right1(i,1)=right1(i,1)/new1(i,2);
new1(i,2)=1;
new1(i+1,2)=new1(i+1,2)-new1(i+1,1)*new1(i,3);
right1(i+1,1)=right1(i+1,1)-right1(i,1)*new1(i+1,1);
new1(i+1,1)=0;
end
right1(col,1)=right1(col,1)/new1(col,2);
new1(col,2)=1;
for i=col:-1:2
right1(i-1,1)=right1(i-1,1)-right1(i,1)*new1(i-1,3);
new1(i-1,3)=0;
end
temp((cz-1)*row+cy,:)=right1(1:col,:);
end
end
mesh(x,y,temp(1:101,1:101))
end

Answers (1)

Walter Roberson
Walter Roberson on 7 May 2014
You say that
the input argument values are coming from the output of other functions
but the error you see is consistent with you not having passed any arguments to the function. Please show how you are invoking the function.
  1 Comment
vinod kumar
vinod kumar on 9 May 2014
thanks for replying.. i am posting the previous function from which the input values are coming to tempmatrix.m the previous function is matrixformation.m...where QV is the input argumenmt whose value is coming from the output of another function. i am sending you the part of matrixformation.m....as it is quite lengthy.....plus there is only repetition of last 8 lines...
function [new, right, top, bottom, south, north, radiation] = matrixformation(QV) T0=27; Tinf=27; sil=5.67E-8; epsilon=0.82; c=560 rho=4420; row=101; col=101; surface=11; he=5; hw=5; hn=5; hs=5; ht=5; hb=5; teta=1; new=zeros(101*101*11,3); right=zeros(101*101*11,1) ; south=right; north=right; top=right; bottom=right ; radiation=zeros(101*101*11,1); delta_t=0.1; % for time=delta_t:delta_t:0.1 temp=T0*ones(101*11,101); for kk=1:11 for jj=1:101 for ii=1:101 if ii==101 xpe=0; else xpe=1; end if ii==1 xwp=0; else xwp=1; end if jj==101 ysp=0; else ysp=1; end if jj==1 ypn=0; else ypn=1; end if kk==1 zpt=0; else zpt=1; end if kk==11 zbp=0; else zbp=1; end
% East-face area. Ae=(ypn/2+ysp/2)*(zpt/2+zbp/2); Aw=Ae;
% North-face area. An=(xpe/2+xwp/2)*(zpt/2 + zbp/2) ; As=An; % Top-face area. At=(xpe/2+xwp/2)*(ypn/2+ysp/2); Ab=At; % The size of the control volume. deltaV=(xpe/2+xwp/2)*(ypn/2+ysp/2)*(zpt/2+zbp/2);
TEMP(1)=0;TEMP(2)=0;TEMP(3)=0;TEMP(4)=0;TEMP(5)=0; TEMP(6)=0; % TP0 is the temperature of the current node. TP0=temp((kk-1)*101+jj,ii);
% T_west=TEMP(l) T_east=TEMP(2) T_north=TEMP(3) % T_south=TEMP(4) T_top=TEMP(5) T bottom=TEMP(6)
if ii==1 TEMP(1)=TP0; elseif ii==col TEMP(2)=TP0; end if jj==1 TEMP(3)=TP0; elseif jj==row TEMP(4)=TP0; end if kk==1 TEMP(5)=TP0; elseif kk==surface TEMP(6)=TP0; end
if (TEMP(1)==0) TEMP(1)=temp((kk-1)*101+jj,ii-1); end if (TEMP(2)==0) TEMP(2)=temp((kk-1)*101+jj , ii+1) ; end if (TEMP(3)==0) TEMP(3)=temp((kk-1)*101+jj-1, ii) ; end if (TEMP(4)==0) TEMP(4)=temp((kk-1)*101+jj+1,ii); end if (TEMP(5)==0) TEMP(5)=temp((kk-2)*101+jj,ii); end if (TEMP(6)==0) TEMP(6)=temp(kk*101+jj,ii) ; end
% Now redefine k's of the neighboring faces with values from NEW K kw=7.2; ke=7.2; kn=7.2; ks=7.2; kt=7.2; kb=7.2;
% Coefficients used in developing the discretised equations. ae=ke*0.001*Ae/xpe; aw=kw*0.001*Aw/xwp; an=kn*0.001*An/ypn; as=ks*0.001*As/ysp; at=kt*0.001*At/zpt; ab=kb*0.001*Ab/zbp; ap0=rho*c*(1/1000000000)*deltaV/delta_t; ap=teta*(ae+aw+an+as+at+ab)+ap0;
% Coefficients used for the wall-medium interface part of the discretised equations. coeffe=he*xpe*0.001/(2*ke+he*xpe*0.001); coeffw=hw*xwp*0.001/(2*kw+hw*xwp*0.001); coeffn=hn*ypn*0.001/(2*kn+hn*ypn*0.001); coeffs=hs*ysp*0.001/(2*ks+hs*ysp*0.001); coefft=ht*zpt*0.001/(2*kt+ht*zpt*0.001); coeffb=hb*zbp*0.001/(2*kb+hb*zbp*0.001); % Radiation coefft for surface b.c. - see thesis... radcoeff=sil*epsilon*zpt*0.001/(2*kt+ht*zpt*0.001); % row_num is the index of the current point in the matrices being used. row_num varies from 1:surface*col*row row_num=(kk-1)*101*101+(jj-1)*101+ii;
% For left-back-top corner if ((kk==1) && (jj==1) && (ii==1)) % Temperature values for current time step for each relevant node. TP0=temp((kk-1)*101+jj,ii); TE0=temp((kk-1)*101+jj,ii+1); TS0=temp((kk-1)*101+jj+1,ii); TB0=temp(kk*101+jj,ii);
new(row_num,2)=ap0+teta*(ae+2*aw*coeffw+2*an*coeffn+as+2*at*coefft+ab); new(row_num,3)=-teta*ae; south(row_num,1)=teta*as; bottom(row_num,1)=teta*ab;
right(row_num,1)=(1-teta)*(ae*TE0+as*TS0+ab*TB0)+(ap0-(1-teta)*(ae+2*aw*coeffw+2*an*coeffn+as+2*at*coefft+ab))*TP0+(2*aw*coeffw+2*an*coeffn+2*at*coefft)*Tinf+QV((kk-1)*101+jj,ii)*deltaV;
radiation(row_num,1)=-2*at*radcoeff;
end end end

Sign in to comment.

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!