Error "It must be of type 'Type::MATLABOutput"

6 vues (au cours des 30 derniers jours)
James Manns
James Manns le 1 Fév 2024
I have a signal x(t)=exp(-100t), t>0. I'm trying to plot the ESD against frequency and then find and plot the 3dB bandwidth. The EDS plots fine but I get the following error for the 3dB plot:
"Error using / Invalid return value '[1/(2*abs(100 + w*1i)^2)]'. It must be of type'Type::MATLABOutput'.
Error in untitled3 (line 22) f_3dB = solve(ESD == max(ESD)/2, f);"
The code is below:
clc
clear all
syms t w;
x_t = exp(-100*t)*(heaviside(t));
X_w = fourier(x_t, w);
ESD = abs(X_w)^2;
% Plot ESD against linear frequency
f = linspace(-10, 10, 1000); % frequency range for plotting
ESD_plot = subs(ESD, w, 2*pi*f);
figure;
plot(f, ESD_plot);
title('Energy Spectral Density (ESD)');
xlabel('Frequency (Hz)');
ylabel('ESD');
grid on;
f_3dB = solve(ESD == max(ESD)/2, f);
Error using /
Invalid return value '[1/(2*abs(100 + w*1i)^2)]'. It must be of type 'Type::MATLABOutput'.
disp(['3 dB Bandwidth: ', num2str(2*f_3dB)]);

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Fév 2024
syms t w;
x_t = exp(-100*t)*(heaviside(t));
X_w = fourier(x_t, w);
ESD = abs(X_w)^2;
% Plot ESD against linear frequency
f = linspace(-10, 10, 1000); % frequency range for plotting
ESD_plot = subs(ESD, w, 2*pi*f);
figure;
plot(f, ESD_plot);
title('Energy Spectral Density (ESD)');
xlabel('Frequency (Hz)');
ylabel('ESD');
grid on;
[maxESD, maxESDidx] = max(ESD_plot);
[~, halfidx] = min( abs(ESD_plot(1:maxESDidx) - maxESD/2) );
f_3dB = double(ESD_plot(halfidx));
disp(['3 dB Bandwidth: ', num2str(2*f_3dB)]);
3 dB Bandwidth: 0.00014339

Plus de réponses (0)

Tags

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by