How to build a graph using stem for a given equation?
Show older comments
As I understand it, the program stumbles over calling the delta function and builds one point. How can I display the desired graph without making the code too heavy?
Main script:
a1=1.7;
b1=9;
subplot(221);
n1=0:20;
x1=a1*delta(n1-b1);
stem(n1, x1);
File delta function (its use is mandatory):
function [ d ] = delta( n )
if n == 0
d = 1;
else
d = 0;
end
end
Accepted Answer
More Answers (1)
Torsten
on 16 Mar 2024
Since your delta function does not support array inputs, you must use something like
x1=a1*arrayfun(@(n1)delta(n1-b1),n1)
instead of
x1=a1*delta(n1-b1);
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!