使用Matlab在VB中使用Laplace变压器 [英] Laplace transformer in VB using matlab
本文介绍了使用Matlab在VB中使用Laplace变压器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好:
我想使用MatLab制造的dll在vb中计算Laplace变压器,但是在vb中运行它会出现自动化错误.该功能在Matlab中可以正常工作.
是:
在matlab中
hello:
I want to calculate Laplace transformer in vb using a dll made in MatLab, but to run it in vb I get an automation error. The function works fine in Matlab.
is:
in matlab
function transf = lap(f)
syms x s
transf=laplace(f,x,s);
end
现在在VB中
Now in VB
Dim lapla As New Laplace.Transformada
Dim resultado As variant
Call lapla.lap(1, resultado, 3 * x)
请帮助.. !!!
我快疯了!
坦克. :confused:
plase help..!!!
I''m going crazy!
tanks. :confused:
推荐答案
using System;
using System.Collections.Generic;
using System.Text;
namespace ComportMath
{
class Laplace
{
public delegate double FunctionDelegate(double t);
static double[] V; // Stehfest coefficients
static double ln2; // log of 2
const int DefaultStehfestN = 14;
static Laplace()
{
InitStehfest(DefaultStehfestN);
}
public static double Transform(FunctionDelegate F, double s)
{
const int DefaultIntegralN = 5000;
double du = 0.5 / (double)DefaultIntegralN;
double y = - F(0) / 2.0;
double u = 0;
double limit = 1.0 - 1e-10;
while (u < limit)
{
u += du;
y += 2.0 * Math.Pow(u, s - 1) * F(-Math.Log(u));
u += du;
y += Math.Pow(u, s - 1) * F(-Math.Log(u));
}
return 2.0 * y * du / 3.0;
}
public static double InverseTransform(FunctionDelegate f, double t)
{
double ln2t = ln2 / t;
double x = 0;
double y = 0;
for (int i = 0; i < V.Length; i++)
{
x += ln2t;
y += V[i] * f(x);
}
return ln2t * y;
}
public static double Factorial(int N)
{
double x = 1;
if (N > 1)
{
for (int i = 2; i <= N; i++)
x = i * x;
}
return x;
}
这篇关于使用Matlab在VB中使用Laplace变压器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文