Finding right function in python based on MatLab code.

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

This code seems not to do much.
The line you refer to is creating a field with the name boundsTransform in the struct Resistivity and assigning an empty double to it.
(@Farzad's "Answer" moved here:)
Thank you for your comment. Could you please send me a link to study more about it.
Thank you.
"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.
Thank you for your comment. It's a part of code. I just wanted to know what type of structure is that. Someone sent me a link that was useful.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

질문:

2022년 7월 29일

댓글:

2022년 7월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by