Clear Filters
Clear Filters

How to get nonlinear function using bode plots data (gain vs. freq and phase vs. freq)

3 views (last 30 days)
Hello,
I'm learning to work with Matlab. Sorry if my question is very basic.
I have 5 set of 19 data points for "gain vs. frequency" and "phase (degrees) vs. frequency". I need to find the nonlinear expression that describes the behavior of this system.
Using system identification, I could get the linear transfer function, zeros and poles. But now I need the nonlinear expression based on this format:
Should I use ifft to transform my bode plots data to time domain? if so, what will be the next step?
Thanks in advance.

Answers (1)

Ayush
Ayush on 2 May 2024
Hi,
In order to find the non-linear expression that describes the behaviour of the given system, I have made use of curve fitting. I will explain an example for "gain vs. frequency" in a similar manner you can try for "phase vs. frequency". To define the non-linear model, I have used "fittype" function, which specifies the model structure, including the names of the independent "x" and dependent "y" variables and the coefficients "a1", "a2", "a3" to be estimated. Then, I used the "fit" function with the frequency data to get the fitted curve "fitresults" and goodness-of-fit statistics "gofs" for each set. This way, you will be able to get the coefficients for the non-linear system that best fits your data. In a similar way, you can implement the above steps for "phase vs frequency". Refer to the example code below for better understanding:
% Example synthetic data
frequency = linspace(1, 10, 19); % Common frequency data for all sets
gain_sets = rand(5, 19); % Each row represents a different set of gain data
modelType = fittype('a1*x + a2*x^2 + a3*x^3', ...
'independent', 'x', ...
'dependent', 'y', ...
'coefficients', {'a1', 'a2', 'a3'}, ...
'options', fitoptions('Method', 'NonlinearLeastSquares', ...
'StartPoint', [0.5, 0.5, 0.5])); % Example start points
fitresults = cell(1, 5); % To store fit results for each set
gofs = cell(1, 5); % To store goodness-of-fit for each set
for i = 1:5
[fitresults{i}, gofs{i}] = fit(frequency(:), gain_sets(i, :)', modelType);
end
% Display the fit result for the first dataset
disp(fitresults{1});
General model: y(x) = a1*x + a2*x^2 + a3*x^3 Coefficients (with 95% confidence bounds): a1 = 0.2353 (-0.03918, 0.5099) a2 = -0.02349 (-0.1066, 0.05958) a3 = 0.0002435 (-0.005751, 0.006238)
figure;
for i = 1:5
V0_pred = feval(fitresults{i}, frequency);
subplot(5, 1, i);
plot(frequency, gain_sets(i, :), 'ro', 'MarkerFaceColor', 'r'); hold on;
plot(frequency, V0_pred, 'b-', 'LineWidth', 2);
xlabel('Frequency');
ylabel(sprintf('Gain Set %d', i));
legend('Original Data', 'Fitted Model');
title(sprintf('Nonlinear Model Fit for Set %d', i));
grid on;
end
Refer to the below documentation for more information on the "fittype" and "fit" functions:

Categories

Find more on Get Started with Control System Toolbox in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!