matlab: toolboxes, technical calculations. numeric integration (1) evaluating integral: computing a...
TRANSCRIPT
MATLAB:toolboxes, technical calculations
Numeric integration (1)• Evaluating integral:
computing a surface below a curve
function y = sinc( x, a)
% the function has to return a vector of functional values y% for the vector of input numbers x
y = log( x+a) .* sin( x)./( x+0.1);
1. Creating m-file, which containsthe integrated function
Numeric integration (2)
function out = integ( low, up)
out = quadl( 'sinc', low, up, 1e-5, [], 0.5);
2. Performing integration by standard m-functionquadl
Numeric integration (3)
syms x a l u
y = int( log( x+a) .* sin( x)./( x+0.1), x, l, u)y = simple( y)
pretty ( y)
Symbolic integration
• Symbolic Math Toolbox:m-function int
h = 0.01; % sampling step
y = sinc( 0:h:1, 0.5);
y1 = diff( y) / h;
y2a = diff( y1) / h;
y2b = diff( y, 2) / h^2;
Numeric differencing (1)
• Differencing performed by standardm-function diff
2
xyxy
dx
dy
x
y(x)
Numeric differencing (2)
syms x a
y1 = diff( log( x+a) .* sin( x)./( x+0.1), 'x', 1)y1 = simple( y1)pretty ( y1)
y2 = diff( log( x+a) .* sin( x)./( x+0.1), 'x', 2)y2 = simple( y2)pretty( y2)
Symbolic differencing
• Symbolic Math Toolbox:m-function diff
Optimization Toolbox (1)
• Searching for such A, B, h, r so thatthe input impedance is Z = (200 + j 0) on the frequency f = 30 GHz
Optimization Toolbox (2)
1. Formulating fitness function:how does the optimized structure fit demands
22 ,,,,,,,,, hBAXXhBARRhBAF rdrdr
hBAF rhBA
,,,min,,,
Optimization Toolbox (3)
2. Creating m-file,which contains the fitness function
function out = mstrip( x)
global net Tmax Rd Xd
Z = Tmax * sim( net, x); % input impedance of the dipoleout = ((Rd-Z(1,:)).*(Rd-Z(1,:)) + (Xd-Z(2,:)).*(Xd-Z(2,:)))';
Optimization Toolbox (4)
3. Performing optimization by OptimizationToolbox m-function fminunc
function x = toolbox
global net Tmax Rd Xd
load dip_616; % loading the antenna model
Rd = 200; % desired value of input resistanceXd = 0; % desired value of input reactance
x0 = [ 5.00; 0.05; 2.00; 1.25]; % A, B, eps, h
x = fminunc('mstrip', x0)