how can i convert python code to matlab?

Please help me, I'm not so familiar with python program. I'm really happy for you

1 Kommentar

  1. t1total_unit_cells = 20total_atoms = 400each_string = int(0.5 * total_atoms / total_unit_cells)z = -1; # the zero index offset
one_row = [] for i in range(total_atoms): one_row.append(0)
matrix = [] for i in range(total_atoms): matrix.append(one_row[:])
for i in range(z + 1, z + total_atoms, 2 * each_string): matrix[z + 1 + i][z + 2 + i] = 't1' matrix[z + 2 + i][z + 1 + i] = 't1'
matrix[z + 1 + i][z + 1 + each_string + i] = 't2'
matrix[z + 1 + each_string + i][z + 1 + i] = 't2'
matrix[z + 2 + each_string + i][z + 3 + each_string + i] = 't3'
matrix[z + 3 + each_string + i][z + 2 + each_string + i] = 't3'
matrix[z + 3 + i][z + each_string + 4 + i] = 't4'
matrix[z + each_string + 4 + i][z + 3 + i] = 't4'
matrix[z + 4 + i][z + each_string + 4 + i] = 't5'
matrix[z + each_string + 4 + i][z + 4 + i] = 't5'
import xlsxwriter
workbook = xlsxwriter.Workbook(f'ped_matrix_uc_{total_unit_cells}_at_{total_atoms}.xlsx') worksheet = workbook.add_worksheet()
row = 0
for col, data in enumerate(matrix): worksheet.write_column(row, col, data)
workbook.close()

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by