Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
From Matlab to Python
#1
Hi all!

I am working on a sound classification project. I have written codes in Matlab, but I need to convert it into Python to use with Raspberry Pi. However, I am not very experienced in Python, so I could not convert some parts of the code.

Here is the Matlab version of the code;

"
clc
close all

load output.mat
d=2*44100;
m=1;
for i=2:41
C1=output{i,1};
r= floor(size(C1,1)/d);
for j=1:r
C1_Data(m,:)=C1(1+((j-1)*d):(d+((j-1)*d)));
m=m+1;
end
"

Here is the Python version which is created by me. However, I could not avoid errors.

"

output = np.concatenate((a1,a2,a3,a4,a5,a6,a7,a8,a9))

d=244100
m=1

C1_Data = pd.DataFrame(reweightTarget, columns = ('Sound Class'))

for i in range(0,43):
C1 = output[i][0]
r = math.floor(C1.size/d)
for j in range (1,r):
s=C1[1+((j-1)d):(d+((j-1)*d))]
C1_Data.loc[m]=[s]
m +=1 "
The error

"index(...) must be called with a collection of some kind 'Sound Class' was passed"


If you can help me solve the problem, I will be grateful.
Reply


Messages In This Thread
From Matlab to Python - by erbab - Oct-27-2020, 01:11 PM
RE: From Matlab to Python - by jefsummers - Oct-27-2020, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Matlab to Python Sateesh 0 1,669 Nov-04-2020, 09:11 AM
Last Post: Sateesh
  Arrays in MATLAB and PYTHON cokhuatlanyeuthuongconhetmuc 2 2,180 Jul-24-2020, 10:47 AM
Last Post: cokhuatlanyeuthuongconhetmuc
  Matlab to Python -- Parallel Computing zistambo 1 1,958 Jun-10-2020, 04:59 PM
Last Post: pyzyx3qwerty
  Python v MatLab for graphs and plots CynthiaMoore 4 3,023 Apr-22-2020, 02:13 PM
Last Post: CynthiaMoore
  python equivalent to MATLAB xcov chai0404 2 3,863 Apr-02-2020, 10:29 PM
Last Post: chai0404
  Python equivalent of Matlab code kwokmaster 1 3,436 Mar-25-2020, 10:14 PM
Last Post: j.crater
  MATLAB to Python conversion stokd 10 4,999 Jan-19-2020, 09:14 PM
Last Post: stokd
  Help converting MATLAB triple-for loop to Python davlovsky 1 1,975 Oct-29-2019, 10:26 PM
Last Post: scidam
  Error -3 when opening matlab file in python python_newbie09 0 2,285 Aug-02-2019, 11:51 AM
Last Post: python_newbie09
  How can I save Python dictionaries in Matlab? jlostinco 1 2,811 Jul-04-2019, 11:35 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020