Effacer les filtres
Effacer les filtres

python call MATLAB function Use Named Arguments

5 vues (au cours des 30 derniers jours)
Michele
Michele le 19 Jan 2024
Commenté : Mike Croucher le 19 Jan 2024
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?

Réponse acceptée

Mike Croucher
Mike Croucher le 19 Jan 2024
Try this
yw = eng.wdenoise(signal, matlab.double(4), "Wavelet","sym2" )
  2 commentaires
Michele
Michele le 19 Jan 2024
Déplacé(e) : Voss le 19 Jan 2024
Thank you!
Mike Croucher
Mike Croucher le 19 Jan 2024
anytime!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Call MATLAB from Python dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by