Welkom bij Python!

Python voor MATLAB-gebruikers

Justin Kiggins

Product Manager

Vereiste voorkennis: matrices manipuleren in MATLAB

% Example of manipulating matrices in MATLAB

v = [16 5 9 4 2 11 7 14];
disp(v(5:end))

A = magic(4);
disp(A(2:4,1:2))

A(A>12) = 10;

disp(A(:,1))
Python voor MATLAB-gebruikers

Vereiste voorkennis: data plotten in MATLAB

% Example of plotting data in MATLAB
figure
plot(t,y,'b-')
xlabel('Time (s)')
ylabel('Sensor A')

figure
scatter(y1,y2,'go')
xlabel('Sensor A')
ylabel('Sensor B')

figure
histogram(y1,[0:0.01:1])
Python voor MATLAB-gebruikers

Vereiste voorkennis: control flow van MATLAB-scripts

% Example of control flow in MATLAB

fid = fopen('magic.m','r');
count = 0;
while ~feof(fid)
    line = fgetl(fid);
    if isempty(line) || strncmp(line,'%',1) || ~ischar(line)
        continue
    end
    count = count + 1;
end
count
Python voor MATLAB-gebruikers

Als je MATLAB niet kent...

Python voor MATLAB-gebruikers

Python gaat verder dan data science

  • Algemene programmeertaal
    • Integreer ML-modellen in grootschalige apps
    • Data opvragen via publieke API's
    • Websites bouwen die veel verkeer aankunnen
Python voor MATLAB-gebruikers

Aan de slag met datatypes

  • Integer
  • Float
  • Boolean
  • String
# Integer
x = 1

print(x)
type(x)
1

<class 'int'>

 

   

 

# Float
x = 1.0  
print(x)

type(x)
1.0

<class 'float'>
Python voor MATLAB-gebruikers

Wiskundige operators

Bewerking Python-operator
Optellen +
Aftrekken -
Vermenigvuldigen *
Delen /
Machtsverheffen **
a = 3 + 12
print(a)
15
b = 4 * 5.0
print(b)
20.0
Python voor MATLAB-gebruikers

$ oppervlakte = \pi r^2 $

radius = 5
pi = 3.14
area = pi * (radius ** 2)
print(area)
78.5

Waarschuwing: Gebruik de dakje-operator ^ NIET

# Dit verheft 4 niet tot de tweede macht
print(4 ^ 2)
# Dit is de bitwise XOR
6
Python voor MATLAB-gebruikers

Laten we beginnen!

Python voor MATLAB-gebruikers

Preparing Video For Download...