Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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




Now in VB

Dim lapla As New Laplace.Transformada
Dim resultado As variant


Call lapla.lap(1, resultado, 3 * x)



plase help..!!!
I'm going crazy!

tanks. :confused:
Posted
Updated 30-Oct-10 13:53pm
v2

1 solution

C#
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;
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900