当前位置: 首页 > news >正文

卡地亚手表官方网站查询浙江响应式网站建设制作

卡地亚手表官方网站查询,浙江响应式网站建设制作,科技之锤,找工作上什么网MATLAB与Python版本的兼容 具体可参看MATLAB与Python版本的兼容 操作说明 操作说明请参看下面两个链接: 操作指南 简单说明: 我安装的是MATLAB2022a和Python3.8.6(安装时请勾选所有可以勾选的,包括路径)。对应版本安…

MATLAB与Python版本的兼容

具体可参看MATLAB与Python版本的兼容

操作说明

操作说明请参看下面两个链接:

  1. 操作指南
    简单说明:
    我安装的是MATLAB2022a和Python3.8.6(安装时请勾选所有可以勾选的,包括路径)。对应版本安装完成后,在MATLAB命令行中敲入执行路劲’D:\SoftwareApps\Python3_7\python.exe’(因人而异)
pyenv('Version','D:\SoftwareApps\Python3_7\python.exe')

完了以后执行下面的操作:

pe = pyenv;
pe.Version

完成后的界面为:
在这里插入图片描述
因为MATLAB更多的是矩阵计算,我们需要安装两个库,一个是numpy,一个是scipy。具体地,我们可以在windows 的操作终端(cmd/terminal)输入python,进入到python可以执行的页面,执行以下命令:

import sys
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install','numpy'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install','scipy'])

完成之后,我们即可开始测试

  1. 测试案例
    (1)MATLAB中的.m文件(call for Python)
% use this link to check if your MATLAB version supports the Python version
% on your computer
% https://www.mathworks.com/support/requirements/python-compatibility.html
% if not, install the Python version that is supportedclc;clear all;% define MATLAB matrices
A1=[1 2;3 4];
A2=[2 3;1 0];% check the conversion types
% https://www.mathworks.com/help/matlab/matlab_external/passing-data-to-python.html
% convert matrices to Python objects
A1converted = py.numpy.array(A1);
A2converted = py.numpy.array(A2);
% parameter to be sent
parameter=py.int(2);% sent the variables, call the python code in "test.py" and obtain the
% return list "result"
[result] = pyrunfile("haha.py","ReturnList",A=A1converted,B=A2converted,param1=parameter);
% link explaining pyrunfile() function:
% https://www.mathworks.com/help/matlab/ref/pyrunfile.html#mw_03ecec06-0677-4345-9112-ea93ac49881e% check the data type of returned variables
class(result)
class(result{1})% convert the Python arrays to MATLAB matrices
C1=double(result{1});
C2=double(result{2});
C3=double(result{3});
C4=double(result{4});% compute the matrices in MATLAB to double check the results
C1check=A1+A2;
C2check=A1*A2;
C3check=eye(2,2);
C4check=inv(A1);

(2)Python中的.py文件(called by MATLAB)

# -*- coding: utf-8 -*-
"""
Code that demonstrates how to run Python code from MATLAB
This is the Python code that is called from MATLAB
Author: Aleksandar Haber 
Date: December 2022The matrices "A" and "B" are passed to Python from MATLAB
The list "ReturnList" is returned to MATLAB"""# You should run these code lines in a separate Python session if the libraries numpy and scipy are not installed
# import sys
# import subprocess
# subprocess.check_call([sys.executable, '-m', 'pip', 'install','numpy'])
# subprocess.check_call([sys.executable, '-m', 'pip', 'install','scipy'])import numpy as np
from scipy import linalgC1 = A + B
C2 = np.matmul(A,B)
C3 = np.eye(param1,param1)
C4 = linalg.inv(A)# this list is returned to MATLAB and later on unpacked in MATLAB
ReturnList=[C1,C2,C3,C4]

具体到一些输入输出的语法,请参看链接:https://www.mathworks.com/help/matlab/ref/pyrunfile.html

参考

[1] https://www.mathworks.com/support/requirements/python-compatibility.html
[2] https://aleksandarhaber.com/tutorial-on-how-to-execute-python-code-directly-matlab/
[3] https://github.com/AleksandarHaber/Execute-Python-Code-From-MATLAB/blob/

http://www.yayakq.cn/news/880859/

相关文章:

  • 有人上相亲网站做传销燕窝做互联网小程序 和网站有没有前景
  • 西青做网站的公司网站版面
  • 手表网站制作西安建筑人才网
  • 网站在开发过程中如何做SEO天津建设网站天津市地铁规划图
  • 南京网站开发联系南京乐识手机上怎么创建wordpress
  • 专业手机网站有哪些做网站一年要多少钱
  • 城乡住房建设网站微营销工具
  • 济南房地产网站建设网站开发成本预算价目表
  • 北京行业网站建设3d做网站
  • 新公司 做网站 流程公司网站建设维护及使用管理办法
  • 石家庄新钥匙网站品牌形象网站源码
  • 乌审旗建设局网站网站上怎样做轮播图
  • 佛山网站建设公司有哪中国采购与招标网官网首页
  • 网站推广怎么做大一python基础编程题
  • 网站建设应该学什么软件做奢侈品的网站
  • 阿里云搭建多个网站泰安房产信息网泰安市房产交易中心
  • 一条龙做网站郑州比较好的电商公司有哪些
  • 揭阳网站开发网站开发速成班
  • 网站建设预算知乎在网上怎么赚钱
  • 做寻亲网站的理由wordpress输出所有页面
  • 献县制作网站盐城市住房和城乡建设局门户网站
  • 在网页做动态图片的网站建设网站建设公司
  • 抚松做网站星月教你做网站回顾文档
  • 网站定制开发是什么欧模网室内设计网官网
  • 北京网站制作计划深圳企业馆设计公司
  • 马蹄室内设计网论坛seo实战密码第三版pdf下载
  • 搜索附近人软件快速优化系统
  • 网站后台管理系统怎么用广州广告公司前100名排行
  • 中国新农村建设网站投稿海淀网站开发公司
  • 可以随意建国际商城的网站吗优化推广网站推荐