Use Matlab in PPT

start Matlab App

Let's take the example of starting the cube cut face demo program in PPT in full screen as an example

1.Start Matlab

2.Enter the command >>enableservice ("AutomationServer", true);

If you do not perform the first two steps, Matlab needs to be started, so there will be a serious delay when running the code for the first time. It is recommended to start first.

3.Start developer tools

PPT-> File-> Options-> Customize Ribbon-> Customize Ribbon-> Check Development Tools-> OK

4.Developer Tools-> visual basic-> Right click on "VBAProject"-> Insert module in project bar-> Enter code

Sub runcube()
   Dim Matlab As New MLApp.MLApp
   result = Matlab.Execute("CubeCut 'FS'")
End SubCode language: VB.NET (vbnet)

5.Developer Tools-> visual basic-> Tools in the menu-> References-> Check Matlab Automation Server Type Library-> OK

6.Return to the PPT and select an object that opens the Matlab program after pressing (pictures, etc.)

For example, create an ellipse: Insert-> Shape-> Select Ellipse-> Place in PPT-> Right-click-> Edit Text-> Write "Cube Cut Program"

6.Insert-> Link-> Action-> Run macro when click the mouse-> Check runcube-> Confirm

7.Start the slide show and click "Cube Cut Program" to start the app in full screen

Exit full screen and press "ESC"

run Matlab code and echo the picture

1.Make sure the developer tools are started (repeat the above three steps (settings take effect in all PPTs, just do it once))

2.Development Tools-> Controls-> Text Box-> Place in PPT

3.Development Tools-> Controls-> Command Buttons-> Placed in PPT

4.Development Tools-> Controls-> Other Controls-> Select "Microsoft LinkPicture Control"-> Place in PPT

5.Right-click the button-> property sheet-> edit the text "Run" in Caption-> close the window

6.Developer Tools-> visual basic-> Tools in the menu-> References-> Check Matlab Automation Server Type Library-> OK

7.Create a folder Matlabtemp on the desktop (recommended in Documents, here is the desktop as an example)

7.Return to the PPT and double-click the button you just created. Enter the following code between Private Sub CommandButton1_Click () and End Sub (the default cursor will be automatically at this position)

Dim Matlab As New MLApp.MLApp
result = Matlab.Execute("set(gcf,'visible','off');enableservice("AutomationServer",true);set(gcf,'Position',get(0,'ScreenSize'));")
h = TextBox1.Value
result = Matlab.Execute(h)
result = Matlab.Execute("print(gcf,'-djpeg','%The folder path just created%\a.jpg');")
InkPicture1.Picture = LoadPicture("%The folder path just created%\a.jpg")
result = Matlab.Execute("close;")
'The replacement text includes the% symbolCode language: VB.NET (vbnet)

8.Return to PPT and start "Slide Show"-> Enter Matlab drawing code in the text box

示例:

syms x y z
f=x^2+y^2==z^2
fimplicit3(f)Code language: Matlab (matlab)

9.Click the button to run the drawing will appear in the created picture box

Precautions

1.When saving PPT, you need to select "Start PowerPoint PowerPoint Presentation" (the suffix is pptm)

 Unless otherwise stated, the articles are original.
 Title of this article:Use Matlab in PPT
 Hyperlink to this article:https://manwish.cn/en/article/use-matlab-in-ppt-2.html

Leave a Comment