Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

how to write algorithm

Asked by Anthony

Anthony (view profile)

on 5 Apr 2014
Latest activity Answered by Star Strider

Star Strider (view profile)

on 5 Apr 2014

Please help me with the algorithm of the formula in the attached file................

1 Comment

Walter Roberson

Walter Roberson (view profile)

on 5 Apr 2014

We can't give an algorithm until you indicate what values are to be input and what values are to be output.

Anthony

Anthony (view profile)

Tags

Products

No products are associated with this question.

2 Answers

Answer by ragesh r menon

ragesh r menon (view profile)

on 5 Apr 2014

What you want to do?

0 Comments

ragesh r menon

ragesh r menon (view profile)

Answer by Star Strider

Star Strider (view profile)

on 5 Apr 2014

Assuming that you may not have the Symbolic Math Toolbox, this should get you started:

syms A E(x) Z b c d E0
Eqn1 = -diff(E,x)/p == (3574/A) * E^(-b) * Z^(c*log(E)+d);
SEqn1 = dsolve(Eqn1, E(0) == E0);   % E(0) == E0, initial condition
SEqn1 = simplify(collect(expand(SEqn1)));
E = matlabFunction(SEqn1)

produces:

 E = @(A,E0,Z,b,c,d,p,x)(-(Z.^d.*p.*x.*3.574e3-A.*E0.^(b+1.0).*exp(-c.*log(E0).*log(Z))+Z.^d.*b.*p.*x.*3.574e3-Z.^d.*c.*p.*x.*log(Z).*3.574e3)./A).^(1.0./(b-c.*log(Z)+1.0));

The rest is yours to solve, since I haven’t shot a proton at a target in a very long time.

It looks rather straightforward, otherwise.

See the MATLAB Online Documentation for details.

0 Comments

Star Strider

Star Strider (view profile)

Contact us