Syntax problem with a user-defined function with sine
3 ビュー (過去 30 日間)
古いコメントを表示
Hello, I need to make this function r(𝜃) = 𝜋(3―sin^5*𝜃) as a user-defined function, but I keep getting the "Error using sin - Not enough input arguments." This is how I defined the function so far:
r(theta)=my_function(pi(3-sin.^5*theta));
How do I fix it?
0 件のコメント
回答 (1 件)
KSSV
2023 年 3 月 3 日
編集済み: KSSV
2023 年 3 月 3 日
function r = my_function(thet)
r = pi*(3-sin(theta)^5) ;
end
Save the above, it will be saved on he name my_function.m. Or copy it under your main function code.
You can also define anonymous function as shown below:
r = @(theta) pi*(3-sin(theta)^5) ;
r(pi/2)
Note: your theta shoould be in radians. If you want theta in degrees either convert it to radians or use sind
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!