Display or get timer object properties
Syntax
Description
get(obj)
displays all property names and their current values for timer object obj
.
V = get(obj)
returns a structure, V
, where each field name is the name of a property of obj
and each field contains the value of that property.
V = get(obj,'
returns the value, PropertyName
') V
, of the timer object property specified in PropertyName
.
If PropertyName
is a1-by-N or N-by-1 cell array of strings containing property names, V
is a 1-by-N cell array of values. If obj
is a vector of timer objects, V
is an M-by-N cell array of property values where M is equal to the length of obj
and N is equal to the number of properties specified.
Example
t = timer;
get(t)
AveragePeriod: NaN
BusyMode: 'drop'
ErrorFcn: []
ExecutionMode: 'singleShot'
InstantPeriod: NaN
LastError: 'none'
Name: 'timer-1'
Period: 1
Running: 'off'
StartDelay: 0
StartFcn: []
StopFcn: []
Tag: ''
TasksToExecute: Inf
TasksExecuted: 0
TimerFcn: []
Type: 'timer'
UserData: []
get(t, {'StartDelay','Period'})
ans =
[0] [1]
getappdata
Get value of application-defined data
Syntax
Description
value = getappdata(h,name)
gets the value of the application-defined data with the name specified by name
, in the object with the handle h
. If the application-defined data does not exist, MATLAB returns an empty matrix in value
.
value = getappdata(h)
returns all application-defined data for the object with handle h
.
getenv
Syntax
Description
getenv 'name'
searches the underlying operating system's environment list for a string of the form name=value
, where name
is the input string. If found, MATLAB returns the string, value
. If the specified name cannot be found, an empty matrix is returned.
N = getenv('name')
returns value
to the variable, N
.
Examples
getfield
Note getfield is obsolete and will be removed in a future release. Please use dynamic field names instead. |
Syntax
Description
f = getfield(s,'field'),
where s
is a 1-by-1 structure, returns the contents of the specified field. This is equivalent to the syntax f = s.field
.
If s
is a structure having dimensions greater than 1-by-1, getfield
returns the first of all output values requested in the call. That is, for structure array s(m,n)
, getfield
returns f
=
s(1,1).field
.
f = getfield(s,{i,j},'field',{k})
returns the contents of the specified field. This is equivalent to the syntax f = s(i,j).field(k)
. All subscripts must be passed as cell arrays--that is, they must be enclosed in curly braces (similar to{i,j}
and {k}
above). Pass field references as strings.
Examples
Then the command f = getfield(mystr,{2,1},'name')
yields
To list the contents of all name (or other) fields, embed getfield
in a loop.
The following example starts out by creating a structure using the standard structure syntax. It then reads the fields of the structure using getfield
with variable and quoted field names and additional subscripting arguments.
class = 5; student = 'John_Doe';
grades(class).John_Doe.Math(10,21:30) = ...
[85, 89, 76, 93, 85, 91, 68, 84, 95, 73];
Use getfield
to access the structure fields.
getframe
Get movie frame
Syntax
Description
returns a movie frame. The frame is a snapshot (pixmap) of the current axes or figure. getframe
F = getframe
gets a frame from the current axes.
F = getframe(h)
gets a frame from the figure or axes identified by the handle h
.
F = getframe(h,rect)
specifies a rectangular area from which to copy the pixmap. rect
is relative to the lower-left corner of the figure or axes h
, in pixel units. rect
is a four-element vector in the form [left bottom width height]
, where width
and height
define the dimensions of the rectangle.
returns a movie frame, which is a structure having two fields:F = getframe(...)
cdata
- The image data stored as a matrix of uint8 values. The dimensions ofF.cdata
are height-by-width-by-3.colormap
- The colormap stored as an n-by-3 matrix of doubles.F.colormap
is empty on true color systems.
To capture an image, use this approach:
[X,Map] = getframe(...)
returns the frame as an indexed image matrix X
and a colormap Map
. This version is obsolete and is supported only for compatibility with earlier version of MATLAB. Since indexed images cannot always capture true color displays, you should use the single output argument form of getframe
. To write code that is compatible with earlier version of MATLAB and that can take advantage of true color support, use the following approach:
Remarks
Usually, getframe
is used in a for
loop to assemble an array of movie frames for playback using movie
. For example,
To create movies that are compatible with earlier versions of MATLAB (before Release 11/MATLAB 5.3) use this approach:
Capture Regions
Note that F = getframe;
returns the contents of the current axes, exclusive of the axis labels, title, or tick labels. F = getframe(
gcf
);
captures the entire interior of the current figure window. To capture the figure window menu, use the form F = getframe(h,rect)
with a rectangle sized to include the menu.
Examples
Make the peaks
function vibrate.
Z = peaks; surf(Z)
axis
tight
set(gca,'nextplot','replacechildren');
for j = 1:20
surf(sin(2*pi*j/20)*Z,Z)
F(j) = getframe;
end
movie(F,20) % Play the movie twenty times
No comments:
Post a Comment