Export Data + Another graphic

조회 수: 1 (최근 30일)
Ana Reis
Ana Reis 2021년 4월 7일
답변: prabhat kumar sharma 2024년 6월 4일
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
prabhat kumar sharma 2024년 6월 4일
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