Using function in a serial code
显示 更早的评论
I have a function shown below:
function [ncell,phis,vac,nccel,ccell] = micro_poly_cell(Nx,Ny,ncell,R)
format long;
phis =zeros(Nx,Ny,ncell);
ncell == 2;
nccel = 0;
ccell(1)=0;
R2 = R*R;
xc(1,1)=70.0;
yc(1,1)=100.0;
xc(1,2)=130.0;
yc(1,2)=100.0;
ncol=1;
nrow=2;
icell =0;
for icol=1:ncol
for irow=1:nrow
icell = icell+1;
dx = xc(icol,irow);
dy = yc(icol,irow);
for i=1:Nx
for j=1:Ny
if((i- dx)*(i-dx) + (j-dy)*(j-dy) < R2)
phis(i,j,icell) =0.999;
end
end
end
end
end
vac(1) = 0.5;
vac(2) =-0.5;
end
It is called in a program as
...
[ncell,phis,vac,nccel,ccell] = micro_poly_cell(Nx,Ny,ncell,R);
...
I have written a new program. I have removed the first and last line of this function and have put the rest of the code in it. The problem is that the output is not the same as with the first program where function is called in a program. So how to correct it?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!