Cannot plot the fourier function "ERROR Data must be numeric, datetime, duration or an array convertible to double"
9 次查看(过去 30 天)
显示 更早的评论
clear all
close all
%Sampling time
Ts=0.001;
t=0:Ts:2*pi;
%Timeaxis
TimeAxes_x = [0 10 0 0.5];
TimeAxes_y = [0 100 0 5000];
%Inverse fourier transform
syms w;
F2 = 1/(1+w^2);
f2 = ifourier(F2,t);
%F2w = 1/(1+t);
%Sampling frequency
fs=1/Ts;
w=(0:length(f2)-1)*fs/length(f2);
graph_subplot(1,211,w,abs(F2),TimeAxes_x,'t(s)','f2(w)','Frequency Doman of f2(t)');
Basically it just tells me that "ERROR Data must be numeric, datetime, duration or an array convertible to double" for that graph_subplot function. That function is basically a plot function. It mainly happens becasue of the w and abs(F2) in the functon. Can someone please help me with this?
采纳的回答
Cris LaPierre
2021-8-25
F2 is a symbolic expression, not numeric. You need to either substitute in values for the symbolic variable w, or use a method for plotting that supports symbolic expressions (e.g. fplot).
%Sampling time
Ts=0.001;
t=0:Ts:2*pi;
%Inverse fourier transform
syms w;
F2 = 1/(1+w^2);
f2 = ifourier(F2,t);
%Sampling frequency
fs=1/Ts;
w2=(0:length(f2)-1)*fs/length(f2);
% substitute
plot(w2,abs(subs(F2,w,w2)))
% fplot
figure
fplot(F2)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

