Could I change a code from jupyternote book to Matlab

1 次查看(过去 30 天)
from fourier_koopman import fourier import numpy as np
x = (np.sin([2*np.pi/24*np.arange(5000)]) + np.sin([2*np.pi/33*np.arange(5000)])).T x = x.astype(np.float32)
f = fourier(num_freqs=2) f.fit(x[:3500], iterations = 1000)
  1 个评论
Joe Vinciguerra
Joe Vinciguerra 2023-7-7
The short answer is "yes". But you would need to know what the python code does, how it works, and the equivalent matlab syntax. The first couple lines are simple, but that last line might give you trouble if you don't have the documentation for the "fourier_koopman" module, or know how to apply it matlab. Additionally, since it's an iterative fitting algorithm using a deep neural network, you'll likely get a different answer in Matlab. Why don't you just use python, or run the python script from matlab?

请先登录,再进行评论。

回答(1 个)

Neev
Neev 2023-7-11
Hey Ahmed
Yes, the above code you shared can be converted to MATLAB and t=you can find the converted code below:-
% importing the libraries
import fourier_koopman.fourier;
import numpy as np;
t = 0:4999;
x = (sin(2*pi/24*t) + sin(2*pi/33*t))';
x = single(x);
f = fourier_koopman.fourier(num_freqs=2);
f.fit(x(1:3500), 'iterations', 1000);
But, before running the above code, you will have to download the fourier koopman module from the 'Add-on Explorer' in the 'Environment' section at 'Home' of MATLAB taskbar.
You can try the above and let me know oif you need any further help.
I hope the information I shared with you will be of help to you:)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by