Could I change a code from jupyternote book to Matlab

조회 수: 4 (최근 30일)
Ahmed Gharieb naga
Ahmed Gharieb naga 2023년 7월 7일
답변: Neev 2023년 7월 11일
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