python call MATLAB function Use Named Arguments
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
How can I call a matlab function with python specifying the name of the arguments?
Es:
in MATLAB:
yw = wdenoise(signal,1,Wavelet='bior3.9',DenoisingMethod='UniversalThreshold', ThresholdRule='Soft', NoiseEstimate='LevelIndependent');
in Python
import matlab.engine
eng = matlab.engine.start_matlab()
signal = matlab.double(signal_noise.values)
yw = eng.wdenoise(signal, matlab.double(4) ) # work!!!
But but when I specify the name of the variable to pass I get an error
yw = eng.wdenoise(signal, matlab.double(4), {'Wavelet': 'sym2'} ) # ERROR !!!
File C:\Program Files\MATLAB\R2023a\toolbox\wavelet\wavelet\wdenoise.m, line 175, in wdenoise Expected at most one numeric input argument in addition to the input data.
I try different mode
yw = eng.wdenoise(signal, matlab.double(4), Wavelet='sym2' ) # ERROR !!!
yw = eng.wdenoise(signal, matlab.double(4), ['Wavelet','sym2'] ) # ERROR !!!
How can I pass specific named arguments?
댓글 수: 0
채택된 답변
Mike Croucher
2024년 1월 19일
Try this
yw = eng.wdenoise(signal, matlab.double(4), "Wavelet","sym2" )
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!