Hi! Can you guys help mi with this code? The error is "Undefined function 'plus' for input arguments of type 'function_handle'."
古いコメントを表示
clc; clear;
rect = @(n) rectangularPulse(-0.5,0.5,n);
sum = 0;
for i=0:7
a = @(n) (rect((n-19*i)/7));
sum = sum + a;
fplot(sum,[0,500]);
end
採用された回答
その他の回答 (1 件)
Geoff Hayes
2016 年 11 月 6 日
Felipe - the error message is due to the line
sum = sum + a;
where you are trying to add a running total (named sum which is a poor choice of a local variable name since it conflicts with a MATLAB built-in function) with an anonymous function a
a = @(n) (rect((n-19*i)/7));
So the error message makes sense. How should you be evaluating a? What should n be?
3 件のコメント
Felipe neut
2016 年 11 月 6 日
編集済み: Felipe neut
2016 年 11 月 6 日
Geoff Hayes
2016 年 11 月 6 日
What should n be? Why have you chosen i to run from zero to seven?
Felipe neut
2016 年 11 月 6 日
編集済み: Felipe neut
2016 年 11 月 6 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

