victorlei / smop

Small Matlab to Python compiler
MIT License
1.08k stars 409 forks source link

add translation for zeros/find/figure/etc #106

Open junxu-ai opened 7 years ago

junxu-ai commented 7 years ago

some functions may be easily added/translated in smop, e.g.,

  1. zeros matlab: zeros(10,10); python zeros((10,10))

  2. find --> nonzeros

  3. figure --> figure()

  4. legend('a','b') -->legend(['a','b'])

5 [A, B] --> c_[A,B] (don't use cat)

6 disp() --> print()

junxu-ai commented 7 years ago

Overall, it's a wonderful project! However, for Python users, some syntax may be confused following matlab rules.

RobBW commented 5 years ago

FYI Some of these functions are implemented at: https://github.com/sendos/matlab_utils_for_python Currently supported and easily used: ischar, datenum, datestr, isempty, fopen, fclose, fprintf, sprintf, size, find, regexprep, regexp, regexpi, randn, rand, ones, zeros, error, length

The “Matlabic” philosophy has been used.

RobBW commented 5 years ago

‘Figure’ is implemented in: https://github.com/sendos/javascript_plots_from_python This is a library that provides access to Matlab-like functions for easily creating javascript plots from within Python. Quote: “The currently supported plotting functions are:

figure, clf, plot, title, xlabel, ylabel, grid, hold, legend, close These functions are to be used with

output_to_flot, output_to_nvd3, output_to_matplotlib in order to visualize your plots.

This library works with the matlab_utils_for_python library which also provides access to several Matlab-like functions and syntax, such as:

Matlab-like arrays, which allow 1-based indexing and also Matlab-like slices x = marray(some_list) y = x[1:3] z = x[1:2:end] Matlab-like ranges for x in mrange[1:3:10]: fprintf('%d\n', x) “ End Quote