Convert for loop Matlab in python
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone, i'd like to convert my Matlab for loop in a Python for loop, but i'am a beginner in Python.
The for loop is:
step=1;
% a,c,k,h are double arrays
cellsize=100;
me=43545;
mn=54656;
x = size(a,1);
y = size(a,2);
R = size((1 : step : x),2);
C = size((1 : step : y),2);
one = zeros(3,R,C);
two = zeros(3,3,R,C);
three = zeros(3,3,R,C);
four = zeros(12,R,C);
pos = zeros(3,1);
jj = 0;
for j = 1 : step : y
jj = jj + 1;
pos(1) = me + cellsize*(j-1);
ii = 0;
for i = 1 : step : x
ii = ii + 1;
pos(2) = mn - cellsize*(i-1);
pos(3) = a(i,j);
s = S(:,i,j);
lia=LIA(:,i,j);
[q w e r] = my_function(pos,c,s,k,h);
one(:,ii,jj) = q;
two(:,:,ii,jj) = w;
three(:,:,ii,jj) = e;
four(:,ii,jj) = r;
end
end
Can you help me please?
0 commentaires
Réponses (1)
Florian Bidaud
le 6 Déc 2022
The equivalent of
for i = start:step:finish
% do something
end
is
for i in range(start, finish+1,step):
#do something
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!