How to match initial index?
Mostrar comentarios más antiguos
I am very close to getting the index in Python to match with Matlab.
Here is the output of Python...
0.06 0.058125 0.05625 0.054375 0.0525 0.050625 0.04875 0.046875 0.045 0.043125 0.04125 0.039375 0.0375 0.035625 0.03375 0.031875 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Here is some of the Matlab code...
% clears variables and windows
clc, clear all
% user defined variables
AoA = 10*pi/180;
Uinf = 8.8;
rho = 1.204;
chord = 0.12;
span = chord*2;
thickness = 0.006;
minRad = thickness/2;
majRad = chord/4;
numPanels = 128;
xp = zeros(numPanels, 1)
yp = zeros(numPanels, 1)
% panel coordinates for a finite thickness plate with elliptical leading % edge (nodes)
xStep = chord/(numPanels/2);
xp = chord/2; % 0.06
yp = 0;
k = 1;
while k < numPanels/8
xp(k) = chord/2 - xStep*k
yp(k) = -minRad/majRad*(majRad^2-(majRad-xStep*k)^2)^(1/2)
k = k + 1;
end
Matlab output...
xp'
ans =
0.0581
0.0562
0.0544
0.0525
0.0506
0.0488
0.0469
0.0450
0.0431
0.0412
0.0394
0.0375
0.0356
0.0338
In Python the first value is 0.06, the value in Matlab is 0.058125. I need to hold numPanels = 128, don't want to change this to match indexing. In my Matlab code before the first while loop I have xp = chord/2 which is the 0.06, while yp = 0. When placing these outside the while loop will Matlab account those as the initial value at index 1?
Respuesta aceptada
Más respuestas (1)
No it is not going to happen, after inside the while loop, the xp and yp variables will be overridden by newly defined xp and yp vectors.
1 comentario
Zach Dunagan
el 20 de Oct. de 2017
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!