Conv function gives unexpected error

2 ビュー (過去 30 日間)
Au.
Au. 2022 年 4 月 11 日
回答済み: Matt J 2022 年 4 月 11 日
Hello everyone,
I am again raising the convolution topic - sorry!
I need to convolute a gaussian, a heaviside and an exponential decay function.
Just using, for example, conv(gaussian,hea,'same') gives me always the following error:
'Subscript indices must either be real positive integers or logicals.'
this is the code i am using:
t=-5:0.1:10;
gaussian=exp(-((t-0.15)/0.164).^2);
hea=(0.2*heaviside(t-0.15));
exp_decay=(exp(-((t-0.15)/0.300)));
func=conv(hea,gaussian,'same');
I found a way arround using the erf fuction, but i do not understand what is the problem... and it would be really useful to be able to use the conv function.
Thank you so much for your answer!
Audrey
  2 件のコメント
Stephen23
Stephen23 2022 年 4 月 11 日
Your code works without error:
t = -5:0.1:10;
gaussian = exp(-((t-0.15)/0.164).^2);
hea = (0.2*heaviside(t-0.15));
exp_decay = (exp(-((t-0.15)/0.300)));
func = conv(hea,gaussian,'same')
func = 1×151
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0022 0.0218 0.1084 0.2907 0.4729
Au.
Au. 2022 年 4 月 11 日
Hello Stefen,
very embarrassed to recognize it does...
thank you for the fast reply!

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

採用された回答

Matt J
Matt J 2022 年 4 月 11 日
Clear the variable called conv from your workspace
clear conv

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by