Azzera filtri
Azzera filtri

How to match initial index?

1 visualizzazione (ultimi 30 giorni)
Zach Dunagan
Zach Dunagan il 20 Ott 2017
Commentato: Zach Dunagan il 21 Ott 2017
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?

Risposta accettata

Birdman
Birdman il 20 Ott 2017
xp(1) = chord/2; % 0.06
yp(1) = 0;
You can make initial value assignments as above and then enter the while loop as you wrote.
  2 Commenti
Zach Dunagan
Zach Dunagan il 20 Ott 2017
Okay thanks for your help._
Zach Dunagan
Zach Dunagan il 21 Ott 2017
That doesn't work. Those initial values don't appear after it loops through...

Accedi per commentare.

Più risposte (1)

Birdman
Birdman il 20 Ott 2017
Modificato: Birdman il 20 Ott 2017
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.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by