Converting from Matlab to Python?
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Shiva Kalyan Diwakaruni
2021 年 5 月 3 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!