How to get nonlinear function using bode plots data (gain vs. freq and phase vs. freq)
조회 수: 3 (최근 30일)
이전 댓글 표시
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/669243/image.jpeg)
Should I use ifft to transform my bode plots data to time domain? if so, what will be the next step?
Thanks in advance.
댓글 수: 0
답변 (1개)
Ayush
2024년 5월 2일
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});
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Control System Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!