フィルターのクリア

How to match initial index?

1 回表示 (過去 30 日間)
Zach Dunagan
Zach Dunagan 2017 年 10 月 20 日
コメント済み: Zach Dunagan 2017 年 10 月 21 日
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?

採用された回答

Birdman
Birdman 2017 年 10 月 20 日
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 件のコメント
Zach Dunagan
Zach Dunagan 2017 年 10 月 20 日
Okay thanks for your help._
Zach Dunagan
Zach Dunagan 2017 年 10 月 21 日
That doesn't work. Those initial values don't appear after it loops through...

サインインしてコメントする。

その他の回答 (1 件)

Birdman
Birdman 2017 年 10 月 20 日
編集済み: Birdman 2017 年 10 月 20 日
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 件のコメント
Zach Dunagan
Zach Dunagan 2017 年 10 月 20 日
Okay... Have any suggestions?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by