Stumped again... Converting Python to Matlab
이전 댓글 표시
Here is the bit of Python code I am trying to convert to Matlab. code:
# thetas for each panel in global frame
theta=np.zeros((numPanels,1))
for i in range(numPanels):
theta[i]=np.arctan2(yp[i+1]-yp[i],xp[i+1]-xp[i])
output:
-2.63356
-2.92712
-2.98475
-3.01668
-3.03837
-3.05471
-3.06785
-3.07891
-3.08853
-3.09713
-3.10498
-3.11228
-3.11917
-3.12577
-3.13217
-3.13846
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.14159
3.13846
3.13217
3.12577
3.11917
3.11228
3.10498
3.09713
3.08853
3.07891
3.06785
3.05471
3.03837
3.01668
2.98475
2.92712
2.63356
0.508031
0.21447
0.156842
0.124909
0.103226
0.0868853
0.0737421
0.0626828
0.053059
0.0444609
0.0366123
0.0293165
0.0224263
0.0158261
0.00942088
0.00312805
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-0.00312805
-0.00942088
-0.0158261
-0.0224263
-0.0293165
-0.0366123
-0.0444609
-0.053059
-0.0626828
-0.0737421
-0.0868853
-0.103226
-0.124909
-0.156842
-0.21447
-0.508031
These are my Matlab arrays, where xpAdd = xp[i+1] and xp = xp[i]
xpAdd =
0.0600
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.0319
0.0300
0.0281
0.0262
0.0244
0.0225
0.0206
0.0188
0.0169
0.0150
0.0131
0.0112
0.0094
0.0075
0.0056
0.0038
0.0019
0
-0.0019
-0.0038
-0.0056
-0.0075
-0.0094
-0.0112
-0.0131
-0.0150
-0.0169
-0.0188
-0.0206
-0.0225
-0.0244
-0.0262
-0.0281
-0.0300
-0.0319
-0.0338
-0.0356
-0.0375
-0.0394
-0.0412
-0.0431
-0.0450
-0.0469
-0.0488
-0.0506
-0.0525
-0.0544
-0.0562
-0.0581
-0.0600
-0.0600
-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.0319
-0.0300
-0.0281
-0.0262
-0.0244
-0.0225
-0.0206
-0.0188
-0.0169
-0.0150
-0.0131
-0.0112
-0.0094
-0.0075
-0.0056
-0.0038
-0.0019
0
0.0019
0.0038
0.0056
0.0075
0.0094
0.0112
0.0131
0.0150
0.0169
0.0188
0.0206
0.0225
0.0244
0.0262
0.0281
0.0300
0.0319
0.0338
0.0356
0.0375
0.0394
0.0412
0.0431
0.0450
0.0469
0.0488
0.0506
0.0525
0.0544
0.0562
0.0581
0.0600
xp' =
0.0600
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.0319
0.0300
0.0281
0.0262
0.0244
0.0225
0.0206
0.0188
0.0169
0.0150
0.0131
0.0112
0.0094
0.0075
0.0056
0.0038
0.0019
0
-0.0019
-0.0038
-0.0056
-0.0075
-0.0094
-0.0112
-0.0131
-0.0150
-0.0169
-0.0188
-0.0206
-0.0225
-0.0244
-0.0262
-0.0281
-0.0300
-0.0319
-0.0338
-0.0356
-0.0375
-0.0394
-0.0412
-0.0431
-0.0450
-0.0469
-0.0488
-0.0506
-0.0525
-0.0544
-0.0562
-0.0581
-0.0600
Does anyone have an idea what this is doing theta[i]=np.arctan2(yp[i+1]-yp[i],xp[i+1]-xp[i]) ? I believe it's finding the angle and x1 and x2 points.
채택된 답변
추가 답변 (1개)
Zach Dunagan
2017년 10월 24일
편집: Walter Roberson
2017년 10월 24일
카테고리
도움말 센터 및 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!