why the plot figure is empty?

조회 수: 4 (최근 30일)
claudia francis
claudia francis 2022년 6월 24일
답변: Yash Srivastava 2022년 6월 28일
i'm trying to plot funcion of t that has sigma of n in it.
it's not showing any errors
Ts = 4;
f = @(t) sinc((t-n*Ts)/Ts);
x1n = sinc(n*4);
x2n = (sinc(n*4/12)).^2;
x3n = cos(pi*n*4/12);
syms n
xr1 = @(t) symsum(x1n.*f,n,-13,13);
syms n
xr2 = @(t) symsum(x2n.*f,n,-13,13);
syms n
xr3 = @(t) symsum(x3n.*f,n,-13,13);
figure(1)
fplot(xr1,[-13 13])
title("x_1[n]")
figure(2)
fplot(xr2,[-13 13])
title("x_2[n]")
figure(3)
fplot(xr3,[-13 13])
title("x_3[n]")
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2022년 6월 24일
sinc(0) throws off an error in symbolic usage
syms x1n(n)
x1n(n) = sinc(n*4)
x1n(n) = 
x1n(0)
Error using symengine
Division by zero.

Error in sym/subs>mupadsubs (line 168)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);

Error in sym/subs (line 153)
G = mupadsubs(F,X,Y);

Error in symfun/feval>evalScalarFun (line 42)
y = subs(formula(Ffun), Fvars, inds);

Error in symfun/feval (line 28)
varargout{1} = evalScalarFun(F, Fvars, varargin);

Error in indexing (line 210)
B = feval(A, inds{:});

댓글을 달려면 로그인하십시오.

채택된 답변

Yash Srivastava
Yash Srivastava 2022년 6월 28일
Hi Claudia
I have modified your code a little bit. Instead of using function handle, we can directly use the expression treating n and t of "syms" type.
Also, sinc(x) = sin(pi*x) / pi*x, will result into "division by 0" error. Therefore, in xr1, xr2 and xr3 I have changed the range of n from [-13 13] to [1 13] to avoid that error.
clear;
syms n t
Ts = 4;
f = sinc((t-n*Ts)/Ts);
x1n = sinc(n*4);
x2n = (sinc(n*4/12)).^2;
x3n = cos(pi*n*4/12);
xr1 = symsum(x1n.*f,n,1,13);
xr2 = symsum(x2n.*f,n,1,13);
xr3 = symsum(x3n.*f,n,1,13);
figure(1)
fplot(xr1,[-13 13])
title("x_1[n]")
figure(2)
fplot(xr2,[-13 13])
title("x_2[n]")
figure(3)
fplot(xr3,[-13 13])
title("x_3[n]")

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by