120 likes | 232 Views
MATLAB: toolboxes, technical calculations. Numeric integration (1). Evaluating integral: computing a surface below a curve. Numeric integration (2). Creating m-file, which contains the integrated function. function y = sinc( x , a )
E N D
Numeric integration (1) • Evaluating integral:computing a surface below a curve
Numeric integration (2) • Creating m-file, which containsthe integrated function 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);
Numeric integration (3) • Performing integration by standard m-functionquadl function out = integ( low, up) out = quadl( 'sinc', low, up, 1e-5, [], 0.5);
Symbolic integration • Symbolic Math Toolbox:m-function int syms x a l u y = int( log( x+a) .* sin( x)./( x+0.1), x, l, u) y = simple( y) pretty( y)
Numeric differencing (1) • Differencing performed by standardm-function diff 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;
Symbolic differencing • Symbolic Math Toolbox:m-function diff 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)
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) • Formulating fitness function:how does the optimized structure fit demands
Optimization Toolbox (3) • 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 dipole out = ((Rd-Z(1,:)).*(Rd-Z(1,:)) + (Xd-Z(2,:)).*(Xd-Z(2,:)))';
Optimization Toolbox (4) • 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 resistance Xd = 0; % desired value of input reactance x0 = [ 5.00; 0.05; 2.00; 1.25]; % A, B, eps, h x = fminunc('mstrip', x0)