How to convert this equation to code?

2 ビュー (過去 30 日間)
Bruh
Bruh 2022 年 7 月 9 日
コメント済み: Bruh 2022 年 7 月 9 日
I think it is x*sqrt((16-x**2)**3)) but it didnt wort

回答 (3 件)

Alan Stevens
Alan Stevens 2022 年 7 月 9 日
Use ^ not **

Chandrika
Chandrika 2022 年 7 月 9 日
As per my understanding, you want the MATLAB code for the given expression. Please try using the following code for the same:
y=x*sqrt(cube((16-sqr(x))))
function square=sqr(x)
square=x*x;
end
function cuben=cube(x)
cuben=x*x*x;
end
You can check the above script by computing 'y' for different values of x.
Hope this helps!

Sam Chak
Sam Chak 2022 年 7 月 9 日
Hi Bruh, First, it's because you used the Python code. Second, bracket issue. Try this instead:
x.*sqrt((16 - x.^2).^3)
  1 件のコメント
Bruh
Bruh 2022 年 7 月 9 日
How about convert the formula to phyton code?

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

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by