Solved

how to merge delphoi and matlab code

Posted on 2009-04-07
4
438 Views
Last Modified: 2016-02-10
what is the baset way to call delphi functions from matlab ? we use win2K and D7

our application has a Tcp interface, is there a corrsponding TCP Indy component in matlab ?
0
Comment
Question by:BdLm
  • 3
4 Comments
 
LVL 12

Accepted Solution

by:
Hypo earned 500 total points
ID: 24094452
Hi,
I don't have access to matlab right now so I can't test this, but I think the best/only way is to compile your delphi functions into a library (dll), where you export the functions you want to use in matlab; then you import this library into your matlab project, and call the exported functions from your algorithms.

You should read this documentation about shared libraries for how you do this in matlab:
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_external/f23224dfi7.html&http://www.google.se/search?hl=sv&q=matlab+external+dll&meta=&aq=f&oq=matlab+external+dl

You should probably also read up on how to create libraries in delphi:
http://delphi.about.com/od/objectpascalide/a/dlldelphi.htm

Hopefully this is enough to get you started :)

regards
Hypo
0
 
LVL 8

Author Comment

by:BdLm
ID: 24101895
using the dlls from c++ I need the header files to import the functions.  Any good to to that with no /  little manual coding ?
0
 
LVL 8

Author Comment

by:BdLm
ID: 24121954
I think the dll way is a acceptable proposal, but now I failed building my first dll using a unit which has been used many time before, I think that unit is error free, but already when compiling the error happend
 
any idea for that error (i already used madshi)

library Project_dll32_interface;
 

{ Wichtiger Hinweis zur DLL-Speicherverwaltung: ShareMem muss sich in der

  ersten Unit der unit-Klausel der Bibliothek und des Projekts befinden (Projekt-

  Quelltext anzeigen), falls die DLL Prozeduren oder Funktionen exportiert, die

  Strings als Parameter oder Funktionsergebnisse übergeben. Das gilt für alle

  Strings, die von oder an die DLL übergeben werden -- sogar für diejenigen, die

  sich in Records und Klassen befinden. Sharemem ist die Schnittstellen-Unit zur

  Verwaltungs-DLL für gemeinsame Speicherzugriffe, BORLNDMM.DLL.

  Um die Verwendung von BORLNDMM.DLL zu vermeiden, können Sie String-

  Informationen als PChar- oder ShortString-Parameter übergeben. }
 
 

uses

  ShareMem,

  SysUtils,

  Types,

  Classes,

  Dialogs,

  addons in '..\code_shared_libraries\addons.pas',

  _excel_support in '..\code_shared_libraries\_excel_support.pas',

  Unit_vector in 'Unit_vector.pas',

  Unit_DBImageV2 in 'Unit_DBImageV2.pas',

  Unit_log in 'Unit_log.pas' {Form1},

  Unit_TStringList2 in 'Unit_TStringList2.pas',

  TStringList_registry in '..\code_shared_libraries\TStringList_registry.pas' {XMLFileListEditForm},

  IndyClientVersionDLL in 'IndyClientVersionDLL.pas';
 
 

 //  ImageLibraryUnit in '..\code_shared_libraries\ImageLibraryUnit.pas';
 
 

type       FPoint = record

               X: Real;

               Y: Real;

               end;
 
 

procedure DllMessage; export;

begin

  ShowMessage('DLL Version  0.1  Date 09.04.2009') ;

end;
 
 

procedure SetServerParameter(LL, UR : FPoint; ElementName : String;  Rotation:  Integer);  export;

var   i :  Integer;

begin

      //  xx := ll * UR;
 

     i := GetFileSize2(ElementName);

end;
 
 

function GetDLLName ( aVal :  ShortString) :  String;  export;

begin
 

      result := aVal + 'TESTDLL';
 

end;
 
 
 

exports
 

DllMessage         index 0  ,

SetServerParameter index 1  ,

GetDLLName         index 2  ;
 
 

{*******************************************************************************}
 

begin
 
 
 
 

end.

Open in new window

runtime.bmp
0
 
LVL 8

Author Comment

by:BdLm
ID: 24236507
idea with DLL is the best way ,
 
my dll trouble seem to be caused by a destroyed delphi project file , not sure
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 102
firstChar challenge 13 110
Re-position the objects 7 97
Firemonkey webbrowser scrollbars ? 1 29
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now