Help inputting vector into formula

I have a vector Cx=[2:.1:10] of values between 2 and 10. I also have the equation B=acosd((Cx.^2+rba.^2-rca.^2)/(2*Cx*rba)), in which I want to obtain the value B for all of the values of Cx in the vector. I have already stated rba=6 and rca=4.
My issue is, when I run the code, I'm only getting one answer for B instead of multiple for all values of Cx. My entire code is below. Please help. Thanks.
rba=6; rca=4; Cx=[2:.1:10] B=acosd((Cx.^2+rba.^2-rca.^2)/(2*Cx*rba))

回答 (1 件)

Star Strider
Star Strider 2016 年 9 月 13 日

0 投票

You need to vectorise the division as well and it works:
B=acosd((Cx.^2+rba.^2-rca.^2)./(2*Cx*rba));
<VECTORISE HERE

カテゴリ

ヘルプ センター および File ExchangePowertrain Blockset についてさらに検索

タグ

質問済み:

2016 年 9 月 13 日

回答済み:

2016 年 9 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by