Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-11-23, 08:41 PM   #1
高级会员
 
注册日期: 2019-11-21
帖子: 2,897
感谢他人: 0
有 0 帖获得 0 感谢
声望力: 60
poster 正向着好的方向发展
默认 converting between matlab and python [closed]

I am new in python. pleae tell me How I can convert this matlab file to python,

classdef TGrid < handleproperties % properties common for all grids NzEarth % number of Earth layers Nza % number of air layersendmethods %set airLayers for the grid function obj = setAirLayers(obj,varargin) Method = 'fixed height'; % OPTIONS: mirror, Fixed Height, Read From File MaxHeight = 10^6 ; % Fixed height of top nzAir = 15 ; % number of layers InputFile = []; n = length(varargin); if mod(n,2) error('Arguments must occur in pairs') end for k = 1:2:n option = lower(varargin{k}); switch option case 'method' Method = lower(varargin{k+1}); nzAir = 10; case 'maxheight' MaxHeight = varargin{k+1}; case 'nlayers' nzAir = varargin{k+1}; case 'inputfile' InputFile = varargin{k+1}; end end switch Method case 'mirror' dzAir = obj.Dz(obj.Nza+1:obj.Nza+nzAir).*(3.^(0:nzAir-1))'; case 'fixed height' z1_log = log10(obj.Dz(1)); dlogz = (log10(MaxHeight)-z1_log)/(nzAir); z = 10.^(z1_log:dlogz:log10(MaxHeight)); dzAir = diff(z); case 'read from file' fid = fopen(InputFile); [dzAir,nzAir] = fscanf(fid,'%f','inf'); end [n,~] = size(dzAir); if n == 1 dzAir = dzAir.'; end obj.Nza = nzAir; obj.Dz = [dzAir(end:-1:1) ; obj.Dz]; obj.Nz = length(obj.Dz); obj.dualLengths; obj.setIndices; end % setAirLayers end % methodsend % classdef

更多...
poster 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用



所有时间均为北京时间。现在的时间是 05:48 AM


Powered by vBulletin
版权所有 ©2000 - 2021,Jelsoft Enterprises Ltd.

SEO by vBSEO ©2009, Crawlability, Inc.