How should I use this python file in matlab . I need to input two csv files and output is one csv file ,using this python code attached below.
7 ビュー (過去 30 日間)
古いコメントを表示
import os
#import cantera as ct # not required, if not using cantera cti file
import numpy as np
import matplotlib.pyplot as plt
p = 101325.0 # constant pressure
#gas = ct.Solution('Ethanol_31.cti') # ethanol
#gas = ct.Solution('gri30.cti') # ethanol
filename = 'output-0.2.csv' # input data
filenamer = 'reaction-0.2.csv' # input data
data_directory = 'Zeta_0' # output dir
if not os.path.exists(data_directory):
os.makedirs(data_directory)
#=============================================================================#
# if using same/converted cti file as chemkin file
#speciesNames = gas.species_names # each species
#nsp = len(speciesNames) # number of species
#molW = gas.molecular_weights # molecular weights of each species
nsp = 53 # number of species
speciesStart = 6 # species start location in output.csv, assuming starting index=0
# first line
names = []
xIndex = -1
uIndex = -1
TIndex = -1
COIndex = -1
CO2Index = -1
H2Index = -1
H2OIndex = -1
ARIndex = -1
with open(filename) as fi:
line0 = fi.readline()
names = [x.strip() for x in line0.split(',')]
for i in range(len(names)):
if names[i] == 'z' or names[i] == 'z (m)' or names[i] == 'x' or names[i] == 'x (m)':
xIndex = i
elif names[i] == 'u' or names[i] == 'u (m/s)':
uIndex = i
elif names[i] == 'T' or names[i] == 'T (K)':
TIndex = i
elif names[i] == 'CO':
COIndex = i
continue
elif names[i] == 'CO2':
CO2Index = i
continue
elif names[i] == 'H2':
H2Index = i
continue
elif names[i] == 'O2':
O2Index = i
continue
elif names[i] == 'OH':
OHIndex = i
continue
elif names[i] == 'H2O':
H2OIndex = i
continue
elif names[i] == 'CH4':
CH4Index = i
continue
elif names[i] == 'N2':
N2Index = i
continue
elif names[i] == 'AR':
ARIndex = i
continue
fig = plt.figure()
ax1 = plt.subplot(221)
ax2 = plt.subplot(222)
ax3 = plt.subplot(223)
0 件のコメント
回答 (1 件)
Abhishek Kumar
2020 年 12 月 11 日
Hi Aditya, interoperability between matlab and python files can be acheived, you can follow the following link to learn more on this:
0 件のコメント
参考
カテゴリ
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!