Python Forum
Porting a MATLAB program into Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Porting a MATLAB program into Python?
#1
Hello! Everyone,
I am new to Python and i have to port a program written in MATLAB into Python, this program uses plot and that's why i had installed matplotlib, most of the things are working properly, but i stuck with the following MATLAB function.

MATLAB Function

h = plot(___)
 returns a column vector of chart line objects. Use h to modify properties of a specific chart line after it is created. For a list of properties, see Chart Line Properties.


I need this function in Python.
The MATLAB code is as follow:


for i=1:180
hold on;
[x, y] = pol2cart(i*0.0174532925, 100);
h(i) = plot([0,x],[0,y],'g','LineWidth',1);
end
and later this h(i) is used as follow in MATLAB code.

set(h(th),'color','r');
[x0, y0] = pol2cart(th*0.0174532925, 100);
[x, y] = pol2cart(th*0.0174532925, r);
set(h(th),'XData',[x0,x]);
set(h(th),'YData',[y0,y]);
m = plot([0,x0],[0,y0],'r','LineWidth',3);
My Python Program is as follow:

for i in range(1,181):
    [x,y] = pol2cart(i*math.pi/180, MAX_DIST)
    h = ax.plot([0,x], [0,y],color='green')
and

        
        [x0, y0] = pol2cart(theta*math.pi/180, MAX_DIST)
        [x, y] = pol2cart(theta*math.pi/180, distance)
        m = ax.plot([0,x0], [0,y0],color='red', linewidth=3.0)
        ax.plot([x0,x], [y0,y],color='blue')
        plt.pause(PAUSE)
        m.pop(0).remove()
Reply
#2
I'm afraid we don't have any matplotlib specialists here. You might try a more dedicated forum - http://matplotlib.1069221.n5.nabble.com/...rs-f3.html
I can't vouch for the quality of that forum (and in fact I was reluctant to recommend it since there's spam from three days ago) but thought this would be better than not replying at all; feel free to let us know if you had any luck or not there.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Media Pipe Python Interfacing with MATLAB cmcreecc 1 940 May-30-2024, 07:23 AM
Last Post: TrentErnser
  Help with porting to python3 mason28 3 6,341 Jan-23-2021, 02:48 AM
Last Post: Larz60+
Photo Matlab to Python Sateesh 0 2,123 Nov-04-2020, 09:11 AM
Last Post: Sateesh
  From Matlab to Python erbab 1 2,655 Oct-27-2020, 02:16 PM
Last Post: jefsummers
  Arrays in MATLAB and PYTHON cokhuatlanyeuthuongconhetmuc 2 2,943 Jul-24-2020, 10:47 AM
Last Post: cokhuatlanyeuthuongconhetmuc
  Matlab to Python -- Parallel Computing zistambo 1 2,778 Jun-10-2020, 04:59 PM
Last Post: pyzyx3qwerty
  Python v MatLab for graphs and plots CynthiaMoore 4 4,290 Apr-22-2020, 02:13 PM
Last Post: CynthiaMoore
  python equivalent to MATLAB xcov chai0404 2 4,862 Apr-02-2020, 10:29 PM
Last Post: chai0404
  Porting Applesoft BASIC "DECIDE" to Python RobinHood2020 0 2,095 Mar-29-2020, 06:55 PM
Last Post: RobinHood2020
  Python equivalent of Matlab code kwokmaster 1 4,367 Mar-25-2020, 10:14 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

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