def setup_class(cls): cls.ip = get_ipython() cls.ip.run_cell('import random') cls.ip.run_cell('import numpy as np') if 'USE_OCTAVE' in os.environ: matlab = 'octave' else: matlab = 'matlab' pymat.load_ipython_extension(cls.ip, matlab=matlab)
def setup_class(cls): cls.ip = get_ipython() cls.ip.run_cell('import random') cls.ip.run_cell('import numpy as np') if 'USE_OCTAVE' in os.environ: matlab = 'octave' else: matlab = 'matlab' # We will test the passing of kwargs through to the Matlab or Octave # objects, by assigning the socket address out here: socket_addr = "tcp://127.0.0.1" if sys.platform == "win32" else "ipc:///tmp/pymatbridge-%s"%str(uuid4()) pymat.load_ipython_extension(cls.ip, matlab=matlab, socket_addr=socket_addr)
def setup_class(cls): cls.ip = get_ipython() cls.ip.run_cell('import random') cls.ip.run_cell('import numpy as np') if 'USE_OCTAVE' in os.environ: matlab = 'octave' else: matlab = 'matlab' # We will test the passing of kwargs through to the Matlab or Octave # objects, by assigning the socket address out here: socket_addr = "tcp://127.0.0.1" if sys.platform == "win32" else "ipc:///tmp/pymatbridge-%s" % str( uuid4()) pymat.load_ipython_extension(cls.ip, matlab=matlab, socket_addr=socket_addr)
def setup_class(cls): cls.ip = IPython.InteractiveShell() cls.ip.run_cell('import random') cls.ip.run_cell('import numpy as np') pymat.load_ipython_extension(cls.ip)
# coding: utf-8 # ## Matlab vs. Python # # This notebook uses the python matlab bridge to do some side by side examples for python and matlab # In[4]: import pymatbridge as pymat # In[5]: ip = get_ipython() pymat.load_ipython_extension(ip) # ### Try a plot in matlab # In[6]: get_ipython().run_cell_magic('matlab', '--size 400,350', "t = linspace(0,6*pi,100);\nplot(sin(t))\ngrid on\nhold on\nplot(cos(t), 'r')") # In[7]: get_ipython().magic('matplotlib inline') from matplotlib import pyplot as plt plt.style.use('ggplot') #plt.style.use('dark_background')
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <codecell> import pymatbridge as pymat # <codecell> ip = get_ipython() pymat.load_ipython_extension(ip, matlab='matlabr2010b') # <codecell> subject = 'FP' if subject == 'HT': dt6 = '/biac2/wandell2/data/diffusion/takemura/20120725_3030/150dirs_b2000_2iso_2/dt6.mat' elif subject == 'FP': dt6 = '/biac2/wandell2/data/diffusion/pestilli/20110922_1125/150dirs_b2000_2/dt6.mat' # <codecell> %%matlab -o cc_coords -i dt6 dt6 = dtiLoadDt6(dt6); cc_coords = dtiFindCallosum(dt6.dt6, dt6.b0, dt6.xformToAcpc); # <codecell> cc_coords_mat = cc_coords.read() - 1 # Transform to 0-based indexing cc_coords_mat.shape
%%prun # prun runs Python's profiler on the current cell N = 1e5 scipy.signal.fftconvolve(np.random.rand(N), np.random.rand(N)) # <codecell> # Not a magic, but IPython also allows for running shell commands !ls -lh # <codecell> # The Python-Matlab bridge can be used as a magic import pymatbridge as pymat ip = get_ipython() pymat.load_ipython_extension(ip) # <codecell> # Python variable - a filter cutoff Wn = .2 # <codecell> %%matlab -i Wn -o b b = fir1(30, Wn); # <codecell> import scipy.signal w, h = scipy.signal.freqz(b);