Converting from Matlab to Python?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Felicia Brimigion
el 30 de Abr. de 2021
Respondida: Shiva Kalyan Diwakaruni
el 3 de Mayo de 2021
I have a code in matlab and I need to convert it to python but I do not have any idea how to do it. ANY help would be MUCH appreciated.
I have no idea when to use numpy and append and other functions that don't necessarily need to be specified in matlab.
As of right now, I have only switched "%" to "#" and "disp" to "print"
I have also changed the [start:increment:end] matrices to: range(start,end,increment)
0 comentarios
Respuestas (1)
Shiva Kalyan Diwakaruni
el 3 de Mayo de 2021
Hi,
1) P_og declaration in line 9 can remain the same as list declaration is same in python too
2) You can replace length() with len()
3) Syntax of if and else is little different in python, you can checkout the below resource for that
4) you need to use pow() function in python instead of '^'
5) list accessing in python is done using [] instead of () so you need to replace T(..) to T[] and remember that in matlab indexing starts from 1 unlike python whose list indexing starts from 0
6) You can follow the below cheatsheet to find matlab equivalent functions of python and replace them all
7) You can check out the below resources for sort function in python
Hope it helps,
Thanks
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!