Vector multiplication in equation

12 次查看(过去 30 天)
Andrew Kay
Andrew Kay 2018-12-13
编辑: Stephen23 2018-12-13
I'm trying create values 'x' for the following equation but the values are not what i'm expecting
f=1:0.1:10
x=sqrt(a*b*c/d*e*f)
(With a,b,c being the numerator of the fraction and d,e,f being the denominator)
a,b,c,d,e are all constants in the equation with the only variable being f ranging from 1, 1.1, 1.2,...,...9.8,9.9,10
How would I code this? Thanks

回答(1 个)

Stephen23
Stephen23 2018-12-13
编辑:Stephen23 2018-12-13
Use parentheses to group the denominator together, and use the correct division operator:
x=sqrt((a*b*c)./(d*e*f))
And tested:
>> a = 1;
>> b = 2;
>> c = 3;
>> d = 4;
>> e = 5;
>> f = 1:0.1:10
f =
1.00000 1.10000 1.20000 1.30000 1.40000 1.50000 1.60000 ...
>> x = sqrt((a*b*c)./(d*e*f))
x =
0.54772 0.52223 0.50000 0.48038 0.46291 0.44721 0.43301 ...
Read about the differences between matrix and array operations:
Using basic arithmetic will make no sense until you learn these differences!

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by