Using function in a serial code
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings 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!