# How to convert the equation to MATLab code

815 views (last 30 days)
ayad filemban on 10 Apr 2019
Commented: Steven Lord on 29 Nov 2022 at 15:39
Help converting
Walter Roberson on 10 Apr 2019

Thomas Rosin on 10 Apr 2019
Edited: Thomas Rosin on 10 Apr 2019

Walter Roberson on 19 Jul 2020
Edited: Walter Roberson on 19 Jul 2020
1. MATLAB has no implied multiplication. All multiplication must be explicit with either the .* (corresponding elements, which is usually the desired operation) or * (inner product) operators
2. e to a power is coded as exp() the power
3. division is the ./ operator with the / operator being more like multiplying by the pseudo-inverse
4. powers other than e to something, should be the .^ (element at a time) or ^ (matrix power through generalized inner product) operators.
5. square root is usually most clear and efficient using sqrt() but .^0.5 or nthroot() can be used, and sometimes sqrtm() or ^0.5 are appropriate
For the kinds of equations that are shown here, use .* and ./ and .^ instead of * and / and ^

akram mehenni on 2 Feb 2022
𝐸5 = 𝛼. 𝐸3 . √𝐸4
Walter Roberson on 2 Feb 2022
The equations that were posted have no E3, E4, or E5, so this does not appear to be an answer to the question that was put. How are people to understand this as a solution to the question ?

Marwa Hameed on 12 Aug 2022
Edited: Walter Roberson on 15 Aug 2022
How can I convert
this equation to MATLAB ?
Walter Roberson on 15 Aug 2022
Caution: you have variable names Q_min and Q_max but you are integrating with respect to log(Q) so Q_min and Q_max are limits on log(Q) not limits on Q.
Integrating with respect to a function instead of a variable is always tricky.
Pi = sym(pi);
syms a_0 E G_fi(Q) Q_max Q_min R sigma_Born T log_Q
eqn = sigma_Born == 4*Pi*a_0^2/(T/R) * int(G_fi(exp(log_Q))/(E/R), log_Q, Q_min, Q_max)
eqn =

Vishwajeet on 29 Nov 2022 at 11:11
how can i convert Cu dTu/ dt = F αTu − γ (Tu − Td) to matlab code?
Steven Lord on 29 Nov 2022 at 15:39
See the documentation for the ODE solvers. I'd start with ode45 and the pages listed under Topics at the end of that page.