Finding right function in python based on MatLab code.
3 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have a MatLab code that I wanted to write it down in Python. I am not very expert in MatLab, so I do appreciate it if you could help me.
This is what I want to transfer: Even tell me what is the form of "Resistivity.boundsTransform", will help me a lot. Thank you.
function Resistivity = m2d_readResistivity(file)
Resistivity = [];
Resistivity.boundsTransform = [];
Resistivity.globalBounds = [];
fid = fopen(file,'r');
sLine = fgets( fid );
[sCode, sValue] = strtok( sLine, ':' );
% Which code do we have?
switch (sCode)
case {'format','version'}
Resistivity.version = sValue;
case {'model file','poly file'}
Resistivity.polyFile = sValue;
case {'data file'}
Resistivity.dataFile = sValue;
case {'roughness with prejudice'}
switch sValue
case 'yes'
Resistivity.bRoughnessWithPrejudice = true;
otherwise
Resistivity.bRoughnessWithPrejudice = false;
end
Resistivity.resistivity = zeros(Resistivity.numRegions,nrho);
Resistivity.freeparameter = zeros(Resistivity.numRegions,nrho);
Resistivity.prejudice = zeros(Resistivity.numRegions,2*nrho);
Resistivity.bounds = zeros(Resistivity.numRegions,2*nrho);
end
end
fclose(fid);
end
6 个评论
Walter Roberson
2022-7-30
"Resistivity" and "boundsTransform" do not mean anything special to MATLAB. The code is creating an arbitrary field inside an arbitrary structure, with no special behaviour of any kind invoked.
回答(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!