Main Content

printToFigure

Print scope window to MATLAB figure

Since R2023b

Description

printToFigure(scope) prints the display window of the scope object to a new MATLAB® figure. The figure is visible by default.

fig = printToFigure(scope) prints the display window of the scope object to a new MATLAB figure and returns the handle to the figure.

fig = printToFigure(scope,Visible=flag) shows or hides the MATLAB figure.

example

Examples

collapse all

Use the printToFigure function to print the timescope object display window to a new MATLAB® figure.

View a sine wave on the time scope. This plot shows the default color and style settings of the timescope object.

f = 100;
fs = 1000;
swv = sin(2.*pi.*f.*(0:1/fs:1-1/fs)).';
scope = timescope(SampleRate=fs,...
    TimeSpanSource="property", ...
    TimeSpan=1);
scope(swv);

Change the background color and the axes color of the plot to "white". Set the font color to "black" and the line color to "blue".

scope.BackgroundColor = "white";
scope.AxesColor = "white";
scope.FontColor = "black";
scope.LineColor = "blue";
show(scope)
release(scope)

Print the display of the sine wave to a new MATLAB figure. The function returns a handle to the figure.

scopeFig = printToFigure(scope);

Figure contains an axes object. The axes object contains an object of type image.

The handle to the figure scopeFig lets you modify the appearance and the behavior of the figure window.

Specify a figure name and change the size of the figure to 400-by-250 pixels.

scopeFig.Name="Sine Wave Signal";
scopeFig.NumberTitle="off";
scopeFig.Position=[1 1 400 250];

Figure Sine Wave Signal contains an axes object. The axes object contains an object of type image.

When printing to figure, you can make the figure invisible by setting the Visible argument to false.

scopeFig = printToFigure(scope,Visible=false);

Input Arguments

collapse all

Scope object whose display the function prints to a MATLAB figure, specified as timescope object.

Flag to show the MATLAB figure, specified as true or false.

Data Types: logical

Output Arguments

collapse all

Handle to the MATLAB figure, returned as a Figure object. For more information on the properties of this object, see Figure Properties.

Version History

Introduced in R2023b

See Also

Objects