Ich möchte bitte wissen, wie konvertiert man einen Matlab-Code in Python? gibt es Tools oder Website ?
Matlab-Code:
Code: Alles auswählen
%Informationsbeschaffung - Tables
mat = load(matFile);
tableNames = fieldnames(mat);
tableNum = numel(tableNames);
% Informationsausgabe
fprintf('Found %d tables in \"%s\" ...\n', tableNum, matFile);
% Schaetzung fuer Groesse des Cell-Arrays
appLineNo = (tableNum + 1) * numel(fieldnames(mat.(tableNames{1})));
data = cell(appLineNo, 3);
lineCounter = 0;
% Loop ueber Tables
for tabInd = 1:tableNum
% Informationsbeschaffung Columns
tableName = tableNames{tabInd};
table = mat.(tableName);
colNames = fieldnames(table);
colNum = numel(colNames);
% Informationsausgabe
fprintf('Found %d columns in table \"%s\" ...\n', colNum, tableName);
% Loop ueber Columns und Daten sammeln
timeAxis = table.(colNames{1});
for colInd = 2:colNum
% Informationsbeschaffung fuer Schreiben
colName = colNames{colInd};
column = table.(colName);
% Pruefung ob Dimensionen stimmen
if numel(timeAxis) ~= numel(column)
fprintf(2, 'Jump over \"%s\" due to dimension error ... \n', colName);
continue;
end
% Daten an Sturktur anhaengen
lineCounter = lineCounter + 1;
data(lineCounter, :) = {colName, timeAxis, column};
end
end
% Entfernen �bersch�ssiger Eintraege und schreiben
data = data(1:lineCounter, :);
end
Dan