How do I go about plotting the following function?

1 回表示 (過去 30 日間)
SF
SF 2019 年 10 月 9 日
編集済み: John Doe 2019 年 10 月 10 日
The function I want to plot is x[n] = \delta[n] - \delta[n-a] where a is just a number.
I tried following this tutorial, but I always ended up with out of memory errors.
I know about plotting the impulse function on it's own but this doesn't make any sense to me.
Any and all help is appreciated.
  1 件のコメント
John Doe
John Doe 2019 年 10 月 9 日
Please share your code.

サインインしてコメントする。

回答 (1 件)

John Doe
John Doe 2019 年 10 月 9 日
編集済み: John Doe 2019 年 10 月 10 日
I've used random numbers.
a = 5
n = [1:1:50]';
delta = 10;
x(n,1) = delta - (delta*(n-a))
plot(x,n)
Alternatively, you could leave n as it is without transposing and plot per the below:
a = 5
n = 1:1:50;
delta = 10;
x(n,1) = delta - (delta*(n-a))
plot(x(:,1),n(1,:))
It doesn't make much odds.
  2 件のコメント
SF
SF 2019 年 10 月 9 日
How did you plot this then? I'm getting that x and n aren't the same size.
John Doe
John Doe 2019 年 10 月 10 日
編集済み: John Doe 2019 年 10 月 10 日
This was your size error. I've updated the answer to transpose n in to be the same as x.
size(x)
ans =
50 1
size(n)
ans =
1 50
Please accept answer :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFormatting and Annotation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by