Cannot plot the fourier function "ERROR Data must be numeric, datetime, duration or an array convertible to double"

10 ビュー (過去 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
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).
You cannot just assign a value to w. That just overwrites the symbolic variable. Try using subs.
%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 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by