Conversion of equation to matlab

4 views (last 30 days)
Olivier Simpson
Olivier Simpson on 10 Nov 2022
Edited: Voss on 10 Nov 2022
Hi, Im having some issues converting this equation to code, dont know if im missing some 'code grammer' or anything of the type.
Any help much appreciated as im still relitively new to coding. :)
Code:
WP_ROC = 1./((ROC/np)+(sqrt((2./(0.0028*sqrt((3*Cdo./K)*WSrange)*(1.155./(LDratio*np)))))));

Answers (1)

Voss
Voss on 10 Nov 2022
Edited: Voss on 10 Nov 2022
Original expression:
WP_ROC = 1./((ROC/np)+(sqrt((2./(0.0028*sqrt((3*Cdo./K)*WSrange)*(1.155./(LDratio*np)))))));
% ^^^^^^^^^^^^^^^^^^ inside inner sqrt()
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ denominator under 2
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inside outer sqrt()
Looks like it should be:
WP_ROC = 1./((ROC/np)+(sqrt(2./(0.0028*sqrt(3*Cdo./K))*WSrange)*(1.155./(LDratio*np))));
% ^^^^^^^^ inside inner sqrt()
% ^^^^^^^^^^^^^^^^^^^^^^^ denominator under 2
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inside outer sqrt()
Or, equivalently, but removing extraneous parentheses:
WP_ROC = 1./(ROC/np+sqrt(2./(0.0028*sqrt(3*Cdo./K))*WSrange)*1.155./(LDratio*np));

Categories

Find more on Data Types in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!