Export Data + Another graphic

4 vues (au cours des 30 derniers jours)
Ana Reis
Ana Reis le 7 Avr 2021
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?

Réponses (1)

prabhat kumar sharma
prabhat kumar sharma le 4 Juin 2024
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!

Catégories

En savoir plus sur Get Started with Control System Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by