How to match initial index?
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!