Top Banner
1 © 2015 The MathWorks, Inc. What’s New in MATLAB 2015 Joe Hicklin
67

Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

Apr 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

1© 2015 The MathWorks, Inc.

What’s New in MATLAB 2015

Joe Hicklin

Page 2: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

2

Talks showing off new features

What’s New in Simulink in Releases 2015a and 2015b

– 11:15–11:45

Machine Learning for Predictive Modelling

– 14:30 – 15:15

Development and Testing of Robotic Applications Using MATLAB and

Simulink

– 16:15 – 17:00

Page 3: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

3

A quick look at some new features

MATLAB

Compiler

SDKC/

C

++ Java .NETPython

Page 4: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

4

New Axis Location: origin

x = -10:0.01:10;

plot(x, sinc(x))

Page 5: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

5

New Axis Location: origin

x = -10:0.01:10;

plot(x, sinc(x))

set (gca, 'xaxislocation', 'origin' )

Page 6: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

6

New Axis Location: origin

x = -10:0.01:10;

plot(x, sinc(x))

set( gca, 'xaxislocation', 'origin' )

set( gca, 'yaxislocation', 'origin' )

Page 7: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

7

Bivariate Histograms

x = randn(100000, 1);

histogram(x)

X

Y

Page 8: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

8

Bivariate Histograms

x = randn(100000, 1);

y = x .* randn(100000, 1);

histogram2(x,y)

X

Y

Page 9: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

9

Array Size Limit

Have you done this?% I need an array with a million elements

Page 10: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

10

Array Size Limit

Have you done this?% I need an array with a million elements

V = rand(1000000);

Page 11: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

11

Array Size Limit

Have you done this?% I need an array with a million elements

V = rand(1000000);

What happens now?

Page 12: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

12

Array Size Limit

Have you done this?% I need an array with a million elements

V = rand(1000000);

What happens now?

Error using rand

Requested 1000000x1000000 (7450.6GB) array exceeds maximum array size

preference.

Page 13: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

13

Array Size Limit

Error using rand

Requested 1000000x1000000 (7450.6GB) array exceeds maximum array size

preference.

Page 14: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

14

Working with “Grouped Data”

What is the average departure delay for each airline?

Page 15: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

15

Working with “Grouped Data”

[ groups, airline] = findgroups( T.UniqueCarrier );

Page 16: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

16

Working with “Grouped Data”

meanDelay = splitapply( @mean, T.DepDelay, groups );

Page 17: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

17

Working with “Grouped Data”

[groups, airline] = findgroups(T.UniqueCarrier);

meanDelay = splitapply( @mean, T.DepDelay, groups);

table(airline, meanDelay)

Page 18: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

18

We support many types of hardware

Page 19: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

19

We have added support

for two popular new

systems:

Raspberry Pi 2

900 MHz

Quad core

1 GB ram

And now there are two more

Page 20: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

20

We have added support

for two popular new

systems:

BeagleBone Black

1 GHz

512 MB ram

4GB flash rom

3D Graphics

And now there are two more

Page 21: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

21

Python Integration

MATLAB integrates with several programming languages:

– C/C++

– Java

– FORTRAN

– COM

– .NET

– Python

Page 22: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

22

Call Python from MATLABMATLAB Interface to Python

Java

COM

C/C++

Fortran

.NET

Python

>> s = py.string.Template( ... 'Patient Name: $who')

>> substitute(s,pyargs('who','Smith'))

Patient Name: Smith

Page 23: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

23

Call MATLAB from PythonMATLAB Engine API

C/C++

Fortran

.NET

COM

Python

>>> import matlab.engine>>> eng = matlab.engine.start_matlab()>>> eng.sqrt(9.0)3.0

Page 24: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

24

Deploy MATLAB Components for Python

MATLAB Compiler SDK

– Creates deployable MATLAB components for

integration with applications written in Python

MATLAB

Compiler SDK

C/C ++ Java .NET Python

Page 25: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

25

Graphs in MATLAB

A directed graph

with four nodes

and three edges.

Page 26: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

26

Graphs in MATLAB

A Graph object

Create

Manipulate

Analyze

A GraphPlot object

View

Page 27: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

27

Let’s make a simple Graph

sourceNodes = [ 1 1 1 2 2 3 3 4 5 5 6 7 ];

targetNodes = [ 2 4 8 3 7 4 6 5 6 8 7 8 ];

G = graph( sourceNodes , targetNodes )

G =

graph with properties:

Edges: [12x1 table]

Nodes: [8x0 table]

Page 28: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

28

P = plot(G);

sourceNodes = [1 1 1 2 2 3 3 4 5 5 6 7];

targetNodes = [2 4 8 3 7 4 6 5 6 8 7 8];

Plot a Graph

Page 29: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

29

Plot a Graph

layout( P,'circle' )

Page 30: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

30

Are these drawings of the same graph?

Page 31: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

31

Plot a Graph

layout(P, 'layered' )

Page 32: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

32

Plot a Graph

layout( P, 'force' );

Page 33: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

33

Graphs in MATLAB

load('MinnesotaRoads');

plot(G);

Page 34: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

34

Graphs in MATLAB

G.Nodes( 1:7,: )

ans =

Longitude Latitude

_________ ________

-97.207 49.001

-96.801 49

-95.957 49

-95.931 49

-95.766 49

-95.378 48.999

-97.2 48.972

Page 35: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

35

P = plot(G, 'XData', G.Nodes.Longitude, 'YData', G.Nodes.Latitude);

Graphs in MATLAB

Page 36: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

36

Page 37: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

37

Useful Graph Algorithms

shortestpath Shortest path between two single nodes

shortestpathtree Shortest path tree from node

distances Shortest path distances of all node pairs

bfsearch Breadth-first graph search

dfsearch Depth-first graph search

maxflow Maximum flow in graph

conncomp Connected graph components

minspantree Minimum spanning tree of graph

toposort Topological order of directed acyclic graph

isdag Determine if graph is acyclic

transclosure Transitive closure

transreduction Transitive reduction

Page 38: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

38

Graphs in MATLAB

P.labelnode(cityIDs, cityNames);

Page 39: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

39

Graphs in MATLAB

P.labelnode(cityIDs, cityNames);

Page 40: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

40

Graphs in MATLAB

T = shortestpath(G,Minneapolis,Moorhead);

P.highlight(T,'EdgeColor','r);

Page 41: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

41

Graphs in MATLAB

T = shortestpath(G,Minneapolis,Moorhead);

P.highlight(T,'EdgeColor','r');

Page 42: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

42

Graphs in MATLAB

P.NodeCData = distances(G, Minneapolis);

title('Distance from Minneapolis (miles)');

colorbar

Page 43: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

43

Graphs in MATLAB

P.NodeCData = distances(G, Minneapolis);

title('Distance from Minneapolis (miles)');

colorbar

Page 44: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

44

Minnesota gets a lot of snow.

You plow the snow

Your equipment is in Minneapolis

You don’t have to plow every road

Drivers must be able to get from

every town to every other town

What is the least you must plow?tree = minspantree(G,'root',minneapolis);

highlight(P,tree, 'LineWidth', 3);

Page 45: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

45

Minnesota gets a lot of snow.

You plow the snow

Your equipment is in Minneapolis

You don’t have to plow every road

Drivers must be able to get from

every town to every other town

What is the least you must plow?tree = minspantree(G,'root',minneapolis);

highlight(P,tree, 'LineWidth', 3);

Page 46: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

47

Add-On Explorer

The File Exchange on

MATLAB Central

About 20,000 submissions

An underused resource

Awareness

Complexity

Page 47: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

48

Add-On Explorer

Page 48: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

49

Add-On Explorer

Page 49: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

50

Add-On Explorer

Page 50: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

51

Add-On Explorer

Page 51: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

52

Add-On Explorer

Page 52: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

53

Add-On Explorer

Page 53: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

54

Add-On Explorer

Page 54: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

55

Add-On Manager

demoDrawTubularMesh

Page 55: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

56

Add-On Explorer

Page 56: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

57

Add-On Manager

demoDrawTubularMesh

Page 57: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

58

Add-On Manager

Page 58: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

59

Add-On Manager

Page 59: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

60

Add-On Explorer

I searched for “Vibration”

133 results

“Spectral”

512 results

“Machine Learning”

125 results

Page 60: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

61

Add-On Explorer

Don’t start doing this when you have a deadline!

Vibration

Spectral

Machine Learning

Support Vector

Classify

Detect

Control

Control Phase

Love

Beauty

Truth

Beer

Monkey

Yogurt

133

512

125

226

411

1342

3919

191

26

26

84

10

3

0

Page 61: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

62

MATLAB Execution Engine

MATLAB

Math GraphicsLanguage

R2014b

Graphics

R2015b

Language

“LXE”

Page 62: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

63

MATLAB Execution Engine

Old system had two different execution mechanisms – a JIT and an Interpreter.

New system has a single execution mechanism.

Old JIT was designed for FORTRAN-like constructs within MATLAB.

New JIT is designed for the entire MATLAB language.

Old system had a monolithic architecture that was difficult to extend.

New system has a Modular, Thread-safe, and Platform re-targetable architecture.

Page 63: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

64

MATLAB Execution EnginePerformance Improvement Highlights

Econometrics Toolbox: American Basket Demo executes 60% faster

Image processing with active contours executes 32% faster

SVM classification for Machine Learning executes 12% faster

Examples used in “Speeding up MATLAB” webinar execute 30% faster

k-NN classification for Machine Learning executes 37% faster

Machine Learning classification executes 25% faster

Image Processing executes 15% faster

Performance in Object-Oriented MATLAB Code on File Exchange executes 10-40% faster

Wireless Application demo executes 50% faster

Page 64: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

65

Application Level Benchmarks Jan. 2015

Tests faster with the LXE

0 0 0 0 0

8

29

17

11

8

10

3

0

5

10

15

20

25

30

35

# o

f Tests

~ Same

(43%)Tests slower with LXE

(0%)

99% on par or faster with LXE

64% more than 10% faster

37% more than 25% faster

(57%)

Performance Ratio

Page 65: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

66

Tests slower with the LXE Tests faster with the LXE

Core and Toolbox UPS tests Jan. 2015

Lower-level tests show more variability

213 10

34

133

326340

299

268253

175

31

0

50

100

150

200

250

300

350

400

# o

f Tests

(10%) (55%)

~ Same (35%)

90% on par or faster with LXE

55% more than 10% faster

39% more than 25% faster

Performance Ratio

Page 66: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

67

MATLAB Execution Engine

Summary

R2015b runs MATLAB programs faster than previous releases.

We will to continue to increase performance.

We will add new features more easily and more quickly.

Page 67: Whats New In MATLAB - MathWorks · colorbar. 44 Minnesota gets a lot of snow. You plow the snow Your equipment is in Minneapolis You don’t have to plow every road Drivers must be

68

What’s New in MATLAB 2015

MATLAB

Compiler

SDKC/

C

++ Java .NETPython