A function does not work with an array as an input argument

2 ビュー (過去 30 日間)
Bogdan MP
Bogdan MP 2021 年 10 月 22 日
コメント済み: Bogdan MP 2021 年 10 月 22 日
I have the following function
MyFun = @(a, x) ( integral(@(k) k .* (1 ./ ( 1 + (a*k - x).^2 )), -1, 1) ./ ...
integral(@(k) 1 ./ ( 1 + (a*k - x).^2 ), -1, 1) );
Which is simply
I have a vector (or an array) of data x. Let's say x = 0 : 1 : 10; When I try to call MyFun(-1, x) I get a mistake ''matrix dimensions must agree''. Could you tell me please, how to fix that?

採用された回答

Matt J
Matt J 2021 年 10 月 22 日
args={'ArrayValued',1};
MyFun = @(a, x) ( integral(@(k) k .* (1 ./ ( 1 + (a*k - x).^2 )), -1, 1,args{:}) ./ ...
integral(@(k) 1 ./ ( 1 + (a*k - x).^2 ), -1, 1,args{:}) )

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by