How do I get a function to calculate an output for an input variable that has a range?

13 次查看(过去 30 天)
I would like to put a variable into a function and use a range of values for that particular variable. How would I go about inputting a range. e.g I would like to use the 'diams' range for the function below.
diams=100:100:1000; [I_pol]= Software_Circular_angle_scan(diams);

回答(1 个)

Star Strider
Star Strider 2016-9-9
You don’t provide enough information to give a specific reply. Depending no what you want to do, you will likely have to use element-wise operators (and possibly loops). See Array vs. Matrix Operations for details on using element-wise operators.
  1 个评论
Joshua Welsh
Joshua Welsh 2016-9-9
diams=100:100:1000; [I_pol]= Software_Circular_angle_scan(diams);
The above equation will be fed into:
if true
% code
diam=diams;
%
n_RI = 1.59; % refractive indices
n_wat = 1.337;
%
m = n_RI/n_wat;
%
lam = 488; % wavelength (nm)
I = 1.09e7;
k0 = 2*pi/lam*n_wat;
x = k0*(diam/2);
%
openang_range = 0:0.1:20;
%
nx = length(openang_range);
%
a = zeros(nx,1);
%
parfor j = 1:nx
teta0 = 0;
phi0 = 90;
% a(j,:)=mie(m,x(j));
a(j)= Mie_circle_integral1(m, x, teta0, phi0, openang_range(j));
end;
%
q_pol=a;
I_pol = q_pol .* ((diam'*1e-9/2).^2)*pi * I;
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by