MATLAB Answers

MATLAB to python conversion

조회 수: 2,563(최근 30일)
I have a matlab script and its supporting function scripts. my code uses Image processing toolbox. I want to convert all to python. how can I do it ? And my python code should run independent of MATLAB. Any help .
  댓글 수: 1
KSSV
KSSV 24 May 2018
This question should be posed in Python forum eh?

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

채택된 답변

ES
ES 24 May 2018
편집: KSSV 24 May 2018
I have used libermate for matlab to python conversion. It is awesome!
  댓글 수: 2
Stephen Nagy
Stephen Nagy 2 Jul 2018
I see linux commands but I'm in windows server 2012r2. Are there windows installs too or am I just missing something?

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

추가 답변(1개)

Pranav Chaudhari
Pranav Chaudhari 1 Apr 2021
function makeSong()
%% By YI-WEN CHEN, 2018 / Jarvus Studio
% 1. According to Piano key frequencies (https://en.wikipedia.org/wiki/Piano_key_frequencies),
% we can create its pitch by fundamental frequency.
% 2. Play twingle twingle little star as an example.
% Sessions Overview:
% http://jarvus.dragonbeef.net/note/noteAudio.php
fs = 44100;
% rest
zero = rest(4,fs); % 1.0 sec
zeroh = rest(8,fs); % 0.5 sec
zerohh = rest(16,fs); % 0.25 sec
% eighth note as 0.5 sec
do = key(52,8,fs); %do 1
re = key(54,8,fs); %re 2
mi = key(56,8,fs); %mi 3
fa = key(57,8,fs); %fa 4
so = key(59,8,fs); %so 5
la = key(61,8,fs); %la 6
si = key(63,8,fs); %si 7
% quarter note as 1 sec
do_4 = key(52,4,fs); %do 1
re_4 = key(54,4,fs); %re 2
mi_4 = key(56,4,fs); %mi 3
fa_4 = key(57,4,fs); %fa 4
so_4 = key(59,4,fs); %so 5
la_4 = key(61,4,fs); %la 6
si_4 = key(63,4,fs); %si 7
% make a song
line1 = [ do do so so la la so_4];
line2 = [ fa fa mi mi re re do_4];
line3 = [ so so fa fa mi mi re_4];
line4 = [ so so fa fa mi mi re_4];
line5 = [ do do so so la la so_4];
line6 = [ fa fa mi mi re re do_4];
song = [line1 line2 line3 line4 line5 line6];
plot(song)
sound(song,fs,24);
%audiowrite('star.wav',song,fs,'BitsPerSample',32);
function wave = key(p, n, fs)
t = 0:1/fs:4/n;
idx = 440*2^((p-49)/12);
% method 1 - orginal
wave = (sin(2*pi*idx*t));
% method 2 - exponential decreasing
% tt = 4/n:-1/fs:0;
% wave = (sin(2*pi*idx*t)).*exp(tt);
% wave = wave./max(wave);
% method 3 - triangle decreasing
% mid = (t(1)+t(end))/2;
% tri = -(abs(t-mid)-mid);
% tri = tri./max(tri);
% wave = (sin(2*pi*idx*t)).*tri;
plot(wave)
function wave = rest(n,fs)
t = 0:1/fs:4/n;
tt = 4/n:-1/fs:0;
wave = 0*sin(2*pi*t).*exp(tt);

태그

Community Treasure Hunt

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

Start Hunting!

Translated by