Borrar filtros
Borrar filtros

Converting Python to Matlab

2 visualizaciones (últimos 30 días)
Zach Dunagan
Zach Dunagan el 24 de Oct. de 2017
Respondida: ASHOK KUMAR MEENA el 18 de Abr. de 2022
Spent a few hours on trying to figure out why the outputs are different, no luck. Python and Matlab are in a txt file along with their outputs.
Suggestions on what I should be looking at to resolve the issue?
  2 comentarios
Walter Roberson
Walter Roberson el 24 de Oct. de 2017
We do not have the data or NumPanels to test with.
Zach Dunagan
Zach Dunagan el 24 de Oct. de 2017
Editada: Zach Dunagan el 25 de Oct. de 2017
I figured it out.

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 24 de Oct. de 2017
Editada: Andrei Bobrov el 24 de Oct. de 2017
Small typo in MATLAB code in nu2
nu2 = atan2(-(xc(k)-xp(n))*sin(theta(k))+(yc(k)-yp(n))*cos(theta(n))+(xp(n+1)-xp(n))*sin(theta(n))-(yp(n+1)-yp(n))*cos(theta(n)),(xc(k)-xp(n))*cos(theta(n))+(yc(k)-yp(n))*sin(theta(n))-(xp(n+1)-xp(n))*...
cos(theta(n))-(yp(n+1)-yp(n))*sin(theta(n))); % fixed!
  3 comentarios
Andrei Bobrov
Andrei Bobrov el 24 de Oct. de 2017
Stop Zach!
How?
cos(theta(n)-(yp(n+1)-yp(n))*sin(theta(n)))
or
cos(theta(n))-(yp(n+1)-yp(n))*sin(theta(n))
Zach Dunagan
Zach Dunagan el 24 de Oct. de 2017
Oh... Thanks.

Iniciar sesión para comentar.

Más respuestas (2)

Zach Dunagan
Zach Dunagan el 25 de Oct. de 2017
Editada: Walter Roberson el 25 de Oct. de 2017
How would I insert zeros in the diagonal line of these 128 x 128 matrices?
nSource = -(sin(theta-transpose(theta)))*ups + (cos(theta-transpose(theta)))*wps;
ftSource = cos(theta-transpose(theta))*ups + sin(theta-transpose(theta))*wps;
nVortex = sin(theta-transpose(theta))*upv + cos(theta-transpose(theta))*wpv;
tVortex = cos(theta-transpose(theta))*upv + sin(theta-transpose(theta))*wpv;
  15 comentarios
Zach Dunagan
Zach Dunagan el 28 de Oct. de 2017
Editada: Walter Roberson el 28 de Oct. de 2017
I changed dot to mtimes() or I could use .*
I compare the first dot to second dot of python and everything looks to be lining up. When I compare the normVelFoil outputs they don't line up.
Here is what I changed..
normVelFoil = mtimes(nSource, x(1:end-1, 1)) + mtimes(nVortex, x(end)*ones(numPanels, 1)) + normU;
Zach Dunagan
Zach Dunagan el 28 de Oct. de 2017
I have come to a conclusion the outputs are the same. They are both extremely small values, practically zero.

Iniciar sesión para comentar.


ASHOK KUMAR MEENA
ASHOK KUMAR MEENA el 18 de Abr. de 2022
def Lagrange(x, y, n, xx):
sum = 0
for i in range(0, n + 1):
product = y[i]
for j in range(0, n + 1):
if (i != j):
product = product * (xx - x[j]) / (x[i] - x[j])
sum += product
return sum
def Trapezoidal(h, n, f):
sum = f[0]
for i in range (1, n):
sum = sum + 2 * f[i]
sum = sum + f[n]
ans = h * sum / 2
return ans

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by