MATLAB API engine Python; Simulation results complex comes as nan+nj
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm calling MATLAB functions in python using the MATLAB engine. Whenever, I pass an argument which output should be a complex number it shows [(nan+naj)] for all the values in array. But if output is supposed to be a real number it gives the output.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/972545/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/972550/image.png)
0 Kommentare
Antworten (1)
Sachin Lodhi
am 10 Jan. 2024
Hello Ashraful,
One possible workaround for your problem can be to separate the real and complex part of the number while interfacing between MATLAB and Python. For this you can take the real part and flatten it to make it contiguous. This same thing can be done with complex part.
Once the real and complex arrays are contiguous, you can form a new MATLAB complex vector, which can then be reshaped and transposed to get the matrix in the correct format. Please note that the reshaping and transpose is important since Python is row-major and MATLAB is column-major.
Hope this helps.
Best Regards,
Sachin
0 Kommentare
Siehe auch
Kategorien
Mehr zu Call MATLAB from Python finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!