필터 지우기
필터 지우기

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 CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by