How to embed a series of Gaussians in a Lorentzian just by adding functions?

5 次查看(过去 30 天)
Hey,
I want to have the shown function in Matlab and use it in my simulations and codes. It is a series of Gaussians (which has a narrow band of around 200 MHz) embedded in a broadband Lorentzian function (approximately 50 GHz). Could you please help me with how I can write a function just by adding some functions to show this figure? I know how to do that by, for example, removing some elements from the Lorentzian at that point and using concatenation techniques. But I need to show this function in my code as the sum or subtraction of some functions because I want to do other processes on it. I have attached a zoom-out figure which shows what I mean as a whole. Then in other pictures with numbers, I mostly want to say I need to define these series of Gaussians embedded into a broader Lorentzian in a flexible way such that I can obtain figures 1, 2, and 3 by changing some parameters of the added functions.
Your help is so much appreciated!

回答(1 个)

Rangesh
Rangesh 2023-11-8
Hi Shaily,
I understand that you would like to embed a series of Gaussian curves into a Lorentzian curve. The provided code accomplishes this task.
x = -100:0.1:100; % Define the x-axis range
% Define the parameters for the Gaussians and Lorentzian
gaussians = {[1, 0, 10], [0.5, -40, 1], [0.8, -50, 8],[0.6,-30,5]};
lorentzian = [1, 0, 50];
% Call the function to evaluate the function values
y = gaussiansInLorentzian(x, gaussians, lorentzian);
% Plot the resulting function
plot(x, y);
In the above code, the range of the x-axis is defined as -100 to 100.The parameters for the Gaussians and the Lorentzian are specified. The function gaussiansInLorentzian is called to evaluate the function values. The resulting function is plotted.
function y = gaussiansInLorentzian(x, gaussians, lorentzian)
% x: Input vector
% gaussians: Cell array of Gaussian parameters [amplitude, mean, standard deviation]
% lorentzian: Lorentzian parameters [amplitude, center, width]
% Initialize the output vector
y = zeros(size(x));
% Evaluate each Gaussian component
for i = 1:numel(gaussians)
gaussian = gaussians{i};
y = y + gaussian(1) * exp(-(x - gaussian(2)).^2 / (2 * gaussian(3)^2));
end
% Evaluate the Lorentzian component
y = y + lorentzian(1) ./ ((x - lorentzian(2)).^2 + (lorentzian(3)/2)^2);
end
The gaussiansInLorentzian function takes the input vector x, a cell array of Gaussian parameters gaussians, and Lorentzian parameters lorentzian. It initializes the output vector y and then evaluates each Gaussian component through iteration. The Gaussian components are added to y and later, the Lorentzian component is evaluated and added to y.
You can modify the code according to your requirements, such as changing the range of the x-axis or adjusting the parameters for the Gaussians and the Lorentzian.
I hope this resolves your query.
With regards,
Rangesh.

类别

Help CenterFile Exchange 中查找有关 Cluster Analysis and Anomaly Detection 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by