Export Data + Another graphic
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
prabhat kumar sharma
on 4 Jun 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!
0 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!