Results returned from Matlab Engine API is different than Matlab results
1 view (last 30 days)
Show older comments
Hi.
I am running Matlab R2022b verison. I have installed the Matlab Engine API as well on Python 3.9.7.
I am having a problem with the disperency of the results returned from both. The original code is written in Matlab, and I want to run it using python. When I run Matlab, the output is a variable with 1x18 shape, which values are:
6.14395465881702 0.651575092548687 25 156.250000000000 390.625000000000
0.770530090496081 0.192234457190110 5.32927289961177e-11 1.35764820806248e-10 11.2398708837811
0.0290391963859361 0.0290391963859361 -10.4903501698474 0.388954806990836 0.520706129341726
0.0693651908321199 0.0209738728353181 0.0183603630161085
When running the same code using Matlab Engine API on python, the output is:
6.105234670562155 0.644549638182511 25. 0. 0.
0.784439528813156 0.194095308440285 0.000000000054579 0.000000000137327 10.462903307448205
0.028765657088391 0.028765657088391 -10.510744455041587 0.400946789499116 0.510874395438037
0.067597599702771 0.020581215360076 0.018303702998913
Most out of the outputs are very close to the orignal ones using Matlab, but some variables are completely zeroed, and I noticed these are the values are considered very large in comparison to the output of the other values. Is there a way to fix this?
Thank you.
A small snippit of the python code:
import matlab.engine
matlab = matlab.engine.start_matlab()
path = '...'
matlab.addpath(path)
fs = ..
feats = matlab.compute_feats(data, fs)
matlab.quit()
2 Comments
Walter Roberson
on 13 Aug 2023
What is the basic mathematics beyind the calculations?
And are you doing an optimization of some kind?
Answers (1)
See Also
Categories
Find more on Call MATLAB from Python in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!