Export Data + Another graphic

4 次查看(过去 30 天)
Ana Reis
Ana Reis 2021-4-7
Hey,
I have a circuit in LTSPICE and I alredy exported the data to matlab. I created a plot.
But now, I have to add another plot to it so I can compare both of them. This second plot is a bode dyagram with a transfer function and I can make it work.
Can you guys help please?

回答(1 个)

prabhat kumar sharma
Hi Ana,
I understand that you have already plotted the LTSPICE plot and want to add a new plot to compare.
You can do this by followign below steps:
1.Plot Your LTSPICE Data (Assuming it's done)
2.Define Your Transfer Function
% Define a transfer function, for example, H(s) = (10s + 1) / (s^2 + 10s + 100)
numerator = [10 1]; % Coefficients of the numerator
denominator = [1 10 100]; % Coefficients of the denominator
H = tf(numerator, denominator); % Creates the transfer function
3. Generate the Bode Plot
opts = bodeoptions; % Gets default options for Bode plot
opts.FreqUnits = 'Hz'; % Sets frequency units to Hz (default is rad/s)
% Generate the Bode plot for magnitude only and get the data
[mag,phase,wout] = bode(H, {min(frequency)*2*pi, max(frequency)*2*pi});
magdB = 20*log10(squeeze(mag)); % Convert magnitude to dB
woutHz = wout / (2*pi); % Convert frequency from rad/s to Hz
% Add the Bode magnitude plot to the existing plot
semilogx(woutHz, magdB, 'r--'); % Plotting in red dashed line for distinction
legend('LTSPICE Data', 'Transfer Function Response');
I hope it helps!

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by