unit1.pas

来自「Delphi7编程80例(完全版)」· PAS 代码 · 共 69 行

PAS
69
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,ComObj, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    ListBox1: TListBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  matlab:OleVariant;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Matlab.Execute(Memo1.Text); //执行Matlab命令
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
matlab:=CreateOleObject('Matlab.Application'); //创建一个matlab程序
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var i:Integer;
begin
Memo1.Clear;
Case ListBox1.ItemIndex Of
0:Memo1.Lines.Add('[x,y,z]=peaks;'+#13#10+
                   'meshz(x,y,z);'+#13#10+
                   'axis([-inf inf -inf inf -inf inf]);');
1:Memo1.Lines.Add('[x,y,z]=peaks;'+#13#10+
                   'waterfall(x,y,z);'+#13#10+
                   'axis([-inf inf -inf inf -inf inf]);');
2:Memo1.Lines.Add('[x,y,z]=peaks;'+#13#10+
                   'meshc(x,y,z);'+#13#10+
                   'axis([-inf inf -inf inf -inf inf]);');
3:Memo1.Lines.Add('[x,y,z]=peaks;'+#13#10+
                   'surfc(x,y,z);'+#13#10+
                   'axis([-inf inf -inf inf -inf inf]);');
4:Memo1.Lines.Add('contour3(peaks, 20);'+#13#10+
                   'axis([-inf inf -inf inf -inf inf]);');
5:Memo1.Lines.Add('contour(peaks, 20);');
End;

end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?