問題タブ [numerical-integration]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
matlab - Matlab 数値積分
matlab を使用して x を統合しようとしていますが、そのタスクは次のコマンドを使用して簡単に行うことができます。
問題は、数値積分の実装方法がわからないことです。さまざまな手法を使用して、一定量の間隔を使用して x を統合したいと考えています。
数値積分の構文呼び出しを手伝ってくれる人はいますか? MathWorks サイトはあまり役に立ちません。
また、トラップと呼ばれる方法があることも知っていますが、リーマン和近似など、matlab 内の他の方法を探しています。
アップデート
特に私が探しているのは、x を 8 つの領域に分割し、それらの 8 つの部分を合計する関数です。そのようなことを行うtrapz以外の事前定義された関数はありますか?
そうですね、そんなことは無いという結論に達したと思います。自分で作る必要があります。
matlab - Matlab ode ソルバー: 状態と指定された時間の変更
t=0、すべての初期条件 t=0 y_0=(0,0,0) で一連の ODE (dy/dt) を解いています。さまざまな時点で y の値に数値を追加して (たとえば、t=10 では y1 をその数値に追加し、t=20 では y2 をその数値に追加する必要があります)、方程式を解くことはできますか?
python - f2py、配列を返す Python 関数 (ベクトル値関数)
次の Python では、返された配列に含まれる 5 つの関数func
を統合する必要があります。このコードは、以下を使用して生成された外部 Fortran モジュールを呼び出しますf2py
。
Fortran ルーチンは次のとおりです。
問題は、Fortran が最初の関数のみを に統合していることですfunc(x)
。印刷結果を参照してください。
One way to workarond that is to modify func(x)
to return the value of a given
position in the array of functions:
And then change the Fortran routine to call the function with two parameters:
Which works:
But here func
is called 5 times more than necessary (in the real case func
has above 300 functions, so it will be called 300 times more than necessary).
- Does anyone know a better solution to make Fortran recognizes all the array returned by
func(x)
? In other words, make Fortran buildfx1 = f(x1)
as an array with 5 elements corresponding to the functions infunc(x)
.
OBS: I am compiling using f2py -c --compiler=mingw32 -m trapzdv trapzdv.f90