返回介绍

Python as Glue

发布于 2025-02-25 23:43:36 字数 2035 浏览 0 评论 0 收藏 0

%load_ext rpy2.ipython
%matplotlib inline
%%R
library(lattice)
attach(mtcars)

# scatterplot matrix
splom(mtcars[c(1,3,4,5,6)], main="MTCARS Data")

Matlab works too:

pip install pymatbridge
!pip install --upgrade pymatbridge
Requirement already up-to-date: pymatbridge in /Users/cliburn/anaconda/lib/python2.7/site-packages
Cleaning up...
import pymatbridge as pymat
ip = get_ipython()
pymat.load_ipython_extension(ip)
Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge
Send 'exit' command to kill the server
.MATLAB started and connected!
/Users/cliburn/anaconda/lib/python2.7/site-packages/IPython/nbformat/current.py:19: UserWarning: IPython.nbformat.current is deprecated.

- use IPython.nbformat for read/write/validate public API
- use IPython.nbformat.vX directly to composing notebooks of a particular version

  """)
%%matlab

xgv = -1.5:0.1:1.5;
ygv = -3:0.1:3;
[X,Y] = ndgrid(xgv,ygv);
V = exp(-(X.^2 + Y.^2));
surf(X,Y,V)
title('Gridded Data Set', 'fontweight','b');

! pip install oct2py
Requirement already satisfied (use --upgrade to upgrade): oct2py in /Users/cliburn/anaconda/lib/python2.7/site-packages
Cleaning up...
%load_ext oct2py.ipython
%%octave

A = reshape(1:4,2,2);
b = [36; 88];
A\b
[L,U,P] = lu(A)
[Q,R] = qr(A)
[V,D] = eig(A)
ans =

       60
       -8

L =

  1.00000  0.00000
  0.50000  1.00000

U =

        2        4
        0        1

P =

Permutation Matrix

   0   1
   1   0

Q =

  -0.44721  -0.89443
  -0.89443  0.44721

R =

  -2.23607  -4.91935
  0.00000  -0.89443

V =

  -0.90938  -0.56577
  0.41597  -0.82456

D =

Diagonal Matrix

  -0.37228        0
        0  5.37228

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文