“Comment convertir le code MATLAB en Python” Réponses codées

Matlab à Python

Install SMOP:

$ git clone https://github.com/victorlei/smop
$ cd smop
$ python setup.py install --user

then run:
$ smop file.m
this will convert file.m in file.py
MitchAloha

Comment convertir les scripts matlab en python

matlab code  to python 
Wide-eyed Willet

Comment convertir le code MATLAB en Python

% Grey Wolf Optimizer
function [Alpha_score,Alpha_pos,Convergence_curve]=GWO(SearchAgents_no,Max_iter,lb,ub,dim,fobj)
% initialize alpha, beta, and delta_pos
Alpha_pos=zeros(1,dim);
Alpha_score=inf; %change this to -inf for maximization problems

Beta_pos=zeros(1,dim);
Beta_score=inf; %change this to -inf for maximization problems

_
            
Gadisa Dagne

Comment convertir le code MATLAB en Python

        % Update Alpha, Beta, and Delta
        if fitness<Alpha_score
            Alpha_score=fitness; % Update alpha
            Alpha_pos=Positions(i,:);
        end
        
        if fitness>Alpha_score && fitness<Beta_score
            Beta_score
Gadisa Dagne

Comment convertir le code MATLAB en Python

Delta_pos=zeros(1,dim);
Delta_score=inf; %change this to -inf for maximization problems

%Initialize the positions of search agents
Positions=initialization(SearchAgents_no,dim,ub,lb);
Convergence_curve=zeros(1,Max_iter);
velocity = .3*randn(SearchAgents_no,dim) ;
w=0.5+rand()/2;
l=0;% Loop counter

% Main loop
while l<Max_iter
    for i=1:size(Positions,1)
        
        % Return back the search agents that go beyond the boundaries of the search space
        Flag4ub=Positions(i,:)>ub;
        Flag4lb=Positions(i,:)<lb;
        Positions(i,:)=(Positions(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;
        
        % Calculate objective function for each search agent
        fitness=fobj(Positions(i,:));
        
        
Gadisa Dagne

Réponses similaires à “Comment convertir le code MATLAB en Python”

Questions similaires à “Comment convertir le code MATLAB en Python”

Plus de réponses similaires à “Comment convertir le code MATLAB en Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code