Code covered by the BSD License  

Highlights from
CircuitTool (a Test and Measurement Demo)

image thumbnail

CircuitTool (a Test and Measurement Demo)

by

 

07 Sep 2004 (Updated )

A demonstration test and measurement application with system identification.

circuit_computecutoff(F,Txym)
function Fc = circuit_computecutoff(F,Txym)
%CIRCUIT_COMPUTECUTOFF    Compute the cutoff frequency of 1st-order low-pass filter
%   FC = CIRCUIT_COMPUTECUTOFF(F,TXYM) computes the cutoff
%   frequency FC (Hz) for low-pass filter with transfer function magnitude
%   TXYM(F). F is frequency, in Hz.  
%
% Ex: 
%        load whitenoise
%        [Txy,F] = tfe(Input,Output,2^10,1/Ts,hanning(2^10));
%        Txym = abs(Txy);
%        omegac = circuit_computecutoff(F,Txym)
%
% This file was automatically created by cftool

% Data from dataset "Txym vs. F":
%    X = F:
%    Y = Txym:
%    Unweighted
%
% Copyright 2003-2004 The MathWorks, Inc

% --- Plot data originally in dataset "Txym vs. F"
F = F(:);
Txym = Txym(:);

% --- Create fit "Theory"

% Apply exclusion rule "High Frequency and Low Frequency"
ex_ = logical(zeros(length(F),1));
ex_([[]]) = 1;
ex_ = ex_ | ~(200<F & F<20000);
%NOTE - I had to change the above line, to fix a bug in code generation in R13.
% The original line was:
% ex_ = ex_ & ~(100<F & F<20000);

fo_ = fitoptions('method','NonlinearLeastSquares','Lower',0);
st_ = [0.0001 ];        % Starting point.  Expected value
set(fo_,'Startpoint',st_);
set(fo_,'Exclude',ex_);
ft_ = fittype('sqrt(1 + (2*pi*F).^2*CR^2)./(1 + (2*pi*F).^2*CR^2);' ,...
     'dependent',{'T'},'independent',{'F'},...
     'coefficients',{'CR'});

% Fit this model using new data
cf_ = fit(F,Txym,ft_ ,fo_);
CR = coeffvalues(cf_);
omegac = 1/CR;
Fc = omegac/(2*pi);

Contact us