Conversion of equation to matlab
4 views (last 30 days)
Show older comments
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)))))));
0 Comments
Answers (1)
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));
0 Comments
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!