Anonymous function only returns single answer
3 ビュー (過去 30 日間)
古いコメントを表示
I have a function where its inputs are two arrays. How do I get the function to return an array of values rather than one single value? The value returned for b is -5.6e-4. Thanks
Code shown here:
x=pi:pi/100:2*pi;
y=x.^2;
z = @(a,b) ((sin(a)+cos(b))/((a.^2)+(b.^2)));
b = z(x,y);
0 件のコメント
採用された回答
Matt J
2023 年 3 月 21 日
編集済み: Matt J
2023 年 3 月 21 日
Use the elementwise division operator ./
x=pi:pi/100:2*pi;
y=x.^2;
z = @(a,b) ((sin(a)+cos(b))./((a.^2)+(b.^2)));
b = z(x,y)
2 件のコメント
Matt J
2023 年 3 月 22 日
You're quite welcome, but please Accept-click the answer to indicate that your question is resolved.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!