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?
댓글 수: 1
채택된 답변
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!

