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