Filter löschen
Filter löschen

Why does my function return a single value instead of an array? I need it to return an array so I can plot it.

9 Ansichten (letzte 30 Tage)
%A.3
Dn2 = @(n) (1-exp(-j*pi*n/2))/(j*pi*n);
n5 = [-5:5];
Y=Dn2(n5)

Antworten (1)

Chunru
Chunru am 17 Nov. 2021
Use ./ instead of / for array operation. [Note that there is division by 0 in your equation]
Dn2 = @(n) (1-exp(-1j*pi*n/2))./(j*pi*n);
n5 = [-5:5];
Y=Dn2(n5)
Y =
0.0637 + 0.0637i -0.0000 + 0.0000i -0.1061 + 0.1061i 0.0000 + 0.3183i 0.3183 + 0.3183i NaN + 0.0000i 0.3183 - 0.3183i 0.0000 - 0.3183i -0.1061 - 0.1061i -0.0000 + 0.0000i 0.0637 - 0.0637i

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by