matlab与python混编_python 与matlab 混合编程环境配置(matlab和python混合编程)-Go语言中文社区...

环境:python 3.5

matlab R2016b    注意:matlab2016 支持的python最高版本为3.5

步骤1: 进入此文件夹 运行命令:

python setup.py install

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjUyODA4OQ==,size_16,color_FFFFFF,t_70步骤二:

pip 安装各种包

步骤三: 你就可以使用呢

接下里验张python 和MATLAB 混编,本文作者采用的是python 调用matlab ,

MATLAB代码:

function a = triangle(b,h)

Fs = 1000; % Sampling frequency

T = 1/Fs; % Sampling period

L = 1000; % Length of signal

t = (0:L-1)*T; % Time vector

S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);

%Corrupt the signal with zero-mean white noise with a variance of 4.

X = S + 2*randn(size(t));

figure();

subplot(211);

plot(1000*t(1:50),X(1:50))

title('Signal Corrupted with Zero-Mean Random Noise')

xlabel('t (milliseconds)')

ylabel('X(t)')

Y = fft(X);

P2 = abs(Y/L);

P1 = P2(1:L/2+1);

P1(2:end-1) = 2*P1(2:end-1);

f = Fs*(0:(L/2))/L;

subplot(212)

plot(f,P1)

title('Single-Sided Amplitude Spectrum of X(t)')

xlabel('f (Hz)')

ylabel('|P1(f)|')

a=1

python 代码:

# coding=utf-8

import time

import matlab.engine

import os

eng = matlab.engine.start_matlab()

fs=360

print(eng.triangle(2,3))

os.system("pause")

#time.sleep(10)

#[RR,brady,tachy,PVC,PAC]=eng.ECG_diagnosis(sig,fs)

#print (ans)

eng.quit()

参考:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值