Image of ideal particle

Hello matlab community.
I am working on a project, the first part of the project that ı need to understand basic idea of the code below. Can anybody explain ?
----------------------------------------
function h=simage(img,numcolor,axistype,minimg,maximg);
imscale=0; if ~exist('axistype')
axistype=['image'];
end
if ~exist('minimg') & ~exist('maximg')
imscale=1;
else
if (~exist('maximg'))
maximg=max(img(:));
end
if (~exist('minimg'))
minimg=min(img(:));
end
if (maximg==0 & minimg==0)
minimg=min(img(:));
maximg=max(img(:));
end
end
if ~exist('numcolor') numcolor=64; end
if imscale==0 h=imagesc(img,[minimg maximg]); else h=imagesc(img); end
axis(axistype);
end
------------------------------------------
if you run the code shown below with the first one together , you will see the some figure like a particle. ---------------------------------------
function ipi=ipf(cr,D,w)
ipi=(1-tanh((abs(cr)-D/2)/w))/2;
------------------------------------
For example I do not understand the meaning of exist in the first code. What is it used for ?
I do not have a much time, I look at some matlab books but I can not find anything about the situation. Please help..
Thank you..

Respuestas (1)

dpb
dpb el 11 de Ag. de 2013
Editada: dpb el 11 de Ag. de 2013

0 votos

...For example I do not understand the meaning of exist in the first code. What is it used for ?
I do not have a much time, I look at some matlab books but I can not find anything about the situation.
Well, it would undoubtedly take far less of your valuable time (and be much less annoying(*) here as well) if you were to simply type
doc exist
at the command line first.
(*) Or, if you're going to ask at least don't whine while doing so...

7 comentarios

Image Analyst
Image Analyst el 11 de Ag. de 2013
You can also place the cursor in any function and type F1. Typing control-D will open up the source code (which is usually just a wrapper for a mex file).
engineerOfPhysics
engineerOfPhysics el 11 de Ag. de 2013
I want just some answer. You do not have to give an answer if it is annoying. Sorry.
I spend my time for that. Do not worry about it.
engineerOfPhysics
engineerOfPhysics el 11 de Ag. de 2013
I check the doc exist. Thanks ı forget for a moment. It is so helpfull.
See it is so easy.. to help..
dpb
dpb el 11 de Ag. de 2013
Meanwhile I've wasted my time reading a frivolous question (written with a privileged attitude besides)...
engineerOfPhysics
engineerOfPhysics el 11 de Ag. de 2013
Editada: engineerOfPhysics el 11 de Ag. de 2013
Can I want you to waste your time for my question again :)
Numcolor variable is used for what? I mean when I change the value 64 to another ones image is not changing. What is the mean of that ?
if ~exist('numcolor')
numcolor=64;
end
dpb
dpb el 11 de Ag. de 2013
Editada: dpb el 11 de Ag. de 2013
Searching for numcolor in what you posted shows it isn't used.
The only references to it are in the argument list and the location where it is defined if non-existent. But, there's no reference to it after that point so it's superfluous. For the answer to why you'll have to ask whoever supplied the function to begin with.
engineerOfPhysics
engineerOfPhysics el 11 de Ag. de 2013
I get the particle image using the code
D=12; %diameter
w=1.3; %width
ss=2*fix(D/2+4*w/2)-1;
os=(ss-1)/2;
[xx yy]=ndgrid(-os:os,-os:os); %ideal particle image grid
r=abs(xx+i*yy); %radial coordinate
h=figure(1);
set(h,'posisiton',[100 100 400 400],'color','w');
simage(ipf(r,D,w));
If you use code with two codes up ı wrote, you can see the particle. Yeah as you say numcolor is not used. I remove it from the code, I get exactly same result.
Thanks... I will spend your time in the next again :)

Iniciar sesión para comentar.

Categorías

Preguntada:

el 11 de Ag. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by