Recent

Author Topic: Exchange data between lazarus and matlab  (Read 2996 times)

M.R.O.

  • Newbie
  • Posts: 1
Exchange data between lazarus and matlab
« on: July 22, 2014, 01:14:16 pm »
Hello everyone!,

My task is simple. I want to send data from Lazarus to Matlab then make calculations (Fuzzy logic) and send back result.
Well right now i started with simple code found in web, matlab is turning on but i get error "Project project1 raised exception class 'EOleException' with message: Exception occurred. At address 5B298E".

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil,
  Forms, LResources, Controls, Graphics, Dialogs,
  StdCtrls, db, extctrls, buttons, ComCtrls,
  Spin, types, windows, ComObj, messages, variants, menus;


type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    Matlab: Variant;
    zr,zi: OleVariant;
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  i,j :integer;
  begin
  Matlab := CreateOleObject('Matlab.Application');
  zr := VarArrayCreate([1,16,1,16], varDouble);
  zi := VarArrayCreate([1,1], varDouble);
  for i:= 1 to 16 do
      begin
        for j :=1 to 16 do
      begin
       zr[i,j] := random;
      end;
  end;
  Matlab.PutFullMatrix('CS','base',VarArrayRef(zr),VarArrayRef(zi));
  Matlab.Execute('contour(CS)');
  end;


end.

Matlab 2013a
Lazarus v1.2.4

Thanks
M.R.O.

 

TinyPortal © 2005-2018