How to Read Text File With Strings in Matlab

Text Backdrop
Modifying Properties

You can ready and query graphics object properties using the property editor or the set and go commands.

  • The Property Editor is an interactive tool that enables you to run into and alter object property values.
  • The set and become commands enable you to set and query the values of properties

To change the default value of properties come across Setting Default Property Values.

Text Property Descriptions

This section lists property names along with the types of values each accepts. Curly braces { } enclose default values.

BackgroundColor ColorSpec | {none}

Color of text extent rectangle. This property enables you ascertain a color for the rectangle that encloses the text Extent. For example, the following code creates a text object that labels a plot and sets the background color to light greenish.

  • text(3*pi/4,sin(3*pi/4),...        ['sin(3*pi/4) = ',num2str(sin(3*pi/4))],...        'HorizontalAlignment','centre',...         'BackgroundColor',[.seven .nine .7]);            

For additional features, see the following properties:

  • EdgeColor -- Color of the rectangle's edge ( none by default).
  • LineStyle -- Style of the rectangle's edge line (first prepare EdgeColor ).
  • LineWidth -- Width of the rectangle's edge line (commencement set EdgeColor )
  • Margin -- Increase the size of the rectangle by adding a margin to the existing text extent rectangle.

See as well Drawing Text in a Box in the MATLAB Graphics documentation for an example using background colour with contour labels.

BusyAction cancel | {queue}

Callback routine interruption. The BusyAction belongings enables y'all to control how MATLAB handles events that potentially interrupt executing callback routines. If there is a callback routine executing, after invoked callback routines always try to interrupt it. If the Interruptible holding of the object whose callback is executing is set to on (the default), then interruption occurs at the next betoken where the event queue is processed. If the Interruptible property is gear up to off, the BusyAction property (of the object owning the executing callback) determines how MATLAB handles the consequence. The choices are:

  • cancel -- Discard the result that attempted to execute a second callback routine
  • queue -- Queue the outcome that attempted to execute a second callback routine until the electric current callback finishes
ButtonDownFcn string or part handle

Button press callback routine. A callback routine that executes whenever you printing a mouse button while the arrow is over the text object. Define this routine as a string that is a valid MATLAB expression or the name of an One thousand-file. The expression executes in the MATLAB workspace.

See Function Handle Callbacks for information on how to utilise office handles to define the callback office.

Children matrix (read simply)

The empty matrix; text objects have no children.

Clipping on | {off}

Clipping mode. When Clipping is on, MATLAB does not display any portion of the text that is outside the axes.

Colour ColorSpec

Text color. A three-element RGB vector or i of the predefined names, specifying the text color. The default value for Color is white. Come across ColorSpec for more information on specifying colour.

CreateFcn string or role handle

Callback routine executed during object creation. This belongings defines a callback routine that executes when MATLAB creates a text object. You must ascertain this belongings as a default value for text. For example, the argument,

  • set(0,'DefaultTextCreateFcn',...     'set(gcf,''Pointer'',''crosshair'')')          

defines a default value on the root level that sets the effigy Pointer property to a crosshair whenever you lot create a text object. MATLAB executes this routine after setting all text backdrop. Setting this belongings on an existing text object has no consequence.

The handle of the object whose CreateFcn is being executed is accessible merely through the root CallbackObject property, which you lot can query using gcbo.

See Function Handle Callbacks for information on how to use function handles to define the callback office.

DeleteFcn string or function handle

Delete text callback routine. A callback routine that executes when you delete the text object (e.grand., when you consequence a delete command or clear the axes or figure). MATLAB executes the routine before destroying the object'due south properties and so these values are bachelor to the callback routine.

The handle of the object whose DeleteFcn is being executed is accessible only through the root CallbackObject property, which you tin query using gcbo.

Meet Function Handle Callbacks for information on how to utilize role handles to ascertain the callback function.

EdgeColor ColorSpec | {none}

Colour of edge drawn around text extent rectangle. This property enables yous to specify the color of a box drawn around the text Extent. For case, the post-obit lawmaking draws a scarlet rectangle effectually text that labels a plot.

  • text(3*pi/4,sin(3*pi/4),... '\leftarrowsin(t) = .707',... 'EdgeColor','red');            

For additional features, run into the following backdrop:

  • BackgroundColor -- Color of the rectangle's interior ( none by default).
  • LineStyle -- Style of the rectangle's edge line (starting time fix EdgeColor ).
  • LineWidth -- Width of the rectangle's edge line (first set EdgeColor )
  • Margin -- Increase the size of the rectangle past adding a margin to the existing text extent rectangle.
Editing on | {off}

Enable or disable editing mode. When this property is set to the default off, you cannot edit the text string interactively (i.due east., you must change the String property to modify the text). When this property is set to on, MATLAB places an insert cursor at the first of the text string and enables editing. To apply the new text string

  1. Printing the ESC key.
  2. Clicking in any effigy window (including the electric current figure).
  3. Reset the Editing property to off.

MATLAB then updates the String holding to contain the new text and resets the Editing property to off. You must reset the Editing belongings to on to resume editing.

EraseMode {normal} | none | xor | groundwork

Erase style. This property controls the technique MATLAB uses to depict and erase text objects. Alternative erase modes are useful for creating blithe sequences where controlling the mode individual objects redraw is necessary to ameliorate performance and obtain the desired effect.

  • normal -- Redraw the affected region of the display, performing the 3-dimensional assay necessary to ensure that all objects are rendered correctly. This mode produces the well-nigh authentic film, but is the slowest. The other modes are faster, but exercise not perform a complete redraw and are therefore, less accurate.
  • none -- Do not erase the text when it is moved or destroyed. While the object is still visible on the screen after erasing with EraseMode none, yous cannot print it because MATLAB stores no information near its one-time location.
  • xor -- Describe and erase the text by performing an exclusive OR (XOR) with each pixel index of the screen below it. When the text is erased, information technology does non damage the objects beneath it. Yet, when text is drawn in xor mode, its colour depends on the color of the screen beneath information technology. It is correctly colored simply when over axes background Color, or the figure background Color if the axes Color is set to none.
  • background -- Erase the text by drawing it in the axes background Color, or the figure background Color if the axes Color is fix to none. This damages objects that are behind the erased text, only text is ever properly colored.

    Printing with Nonnormal Erase Modes

MATLAB always prints figures as if the EraseMode of all objects is set to normal. This means graphics objects created with EraseMode set to none, xor, or background can expect differently on screen than on newspaper. On screen, MATLAB may mathematically combine layers of colors (e.g., XORing a pixel color with that of the pixel behind it) and ignore three-dimensional sorting to obtain greater rendering speed. Nevertheless, these techniques are non applied to the printed output.

You can use the MATLAB getframe control or other screen capture awarding to create an image of a figure containing nonnormal manner objects.

Extent position rectangle (read only)

Position and size of text. A four-element read-only vector that defines the size and position of the text string

  •             [left,bottom,width,tiptop]                      

If the Units property is set to data (the default), left and bottom are the x and y coordinates of the lower left corner of the text Extent.

For all other values of Units , left and bottom are the distance from the lower left corner of the axes position rectangle to the lower left corner of the text Extent. width and summit are the dimensions of the Extent rectangle. All measurements are in units specified by the Units property.

FontAngle {normal} | italic | oblique

Character camber. MATLAB uses this property to select a font from those bachelor on your particular system. Mostly, setting this property to italic or oblique selects a slanted font.

FontName A name, such as Courier , or the string FixedWidth

Font family unit. A string specifying the proper name of the font to utilize for the text object. To display and impress properly, this must be a font that your organisation supports. The default font is Helvetica.

Specifying a Fixed-Width Font

If yous want text to utilise a fixed-width font that looks practiced in any locale, you should fix FontName to the string FixedWidth:

  • set(text_handle,'FontName','FixedWidth')          

This eliminates the need to hard lawmaking the name of a fixed-width font, which may not display text properly on systems that do not use ASCII grapheme encoding (such as in Japan where multibyte graphic symbol sets are used). A properly written MATLAB awarding that needs to use a fixed-width font should set FontName to FixedWidth (annotation that this string is example sensitive) and rely on FixedWidthFontName to be set correctly in the end-user'south environment.

End users can adapt a MATLAB application to dissimilar locales or personal environments by setting the root FixedWidthFontName property to the appropriate value for that locale from startup.yard.

Note that setting the root FixedWidthFontName holding causes an immediate update of the display to utilize the new font.

FontSize size in FontUnits

Font size. An integer specifying the font size to use for text in units determined by the FontUnits property. The default betoken size is 10 (ane point = 1/72 inch).

FontWeight low-cal | {normal} | demi | bold

Weight of text characters. MATLAB uses this property to select a font from those available on your item organization. Generally, setting this property to assuming or demi causes MATLAB to use a assuming font.

FontUnits {points} | normalized | inches |
 centimeters | pixels

Font size units. MATLAB uses this property to decide the units used past the FontSize belongings. Normalized units interpret FontSize equally a fraction of the height of the parent axes. When you resize the axes, MATLAB modifies the screen FontSize accordingly. pixels, inches, centimeters, and points are absolute units (ane indicate = 1/72 inch).

HandleVisibility {on} | callback | off

Command access to object's handle by control-line users and GUIs. This property determines when an object'southward handle is visible in its parent's listing of children. HandleVisibility is useful for preventing command-line users from accidentally cartoon into or deleting a figure that contains only user interface devices (such as a dialog box).

Handles are always visible when HandleVisibility is prepare to on.

Setting HandleVisibility to callback causes handles to be visible from within callback routines or functions invoked by callback routines, only non from within functions invoked from the control line. This provides a means to protect GUIs from control-line users, while allowing callback routines to take consummate access to object handles.

Setting HandleVisibility to off makes handles invisible at all times. This may exist necessary when a callback routine invokes a function that might potentially damage the GUI (such as evaluating a user-typed cord), and so temporarily hides its own handles during the execution of that function.

When a handle is non visible in its parent's list of children, information technology cannot be returned by functions that obtain handles by searching the object hierarchy or querying handle properties. This includes become, findobj, gca, gcf, gco, newplot, cla, clf, and shut.

When a handle's visibility is restricted using callback or off:

  • The object's handle does non announced in its parent's Children holding.
  • Figures do non announced in the root'south CurrentFigure property.
  • Objects do not announced in the root's CallbackObject holding or in the figure's CurrentObject property.
  • Axes do not announced in their parent's CurrentAxes property.

Yous can set up the root ShowHiddenHandles property to on to brand all handles visible, regardless of their HandleVisibility settings (this does non bear upon the values of the HandleVisibility backdrop).

Handles that are hidden are still valid. If you know an object'south handle, you can ready and get its properties, and pass information technology to any function that operates on handles.

HitTest {on} | off

Selectable by mouse click. HitTest determines if the text can become the current object (equally returned by the gco control and the figure CurrentObject property) every bit a upshot of a mouse click on the text. If HitTest is set to off, clicking on the text selects the object below it (which is usually the axes containing it).

For example, suppose yous define the button down role of an image (run across the ButtonDownFcn property) to display text at the location you lot click on with the mouse.

Starting time define the callback routine.

  • part bd_function pt = get(gca,'CurrentPoint'); text(pt(one,i),pt(1,2),pt(1,iii),...        '{\fontsize{20}\oplus} The spot to label',...        'HitTest','off')          

At present brandish an prototype, setting its ButtonDownFcn property to the callback routine.

  • load earth image(X,'ButtonDownFcn','bd_function'); colormap(map)          

When yous click on the image, MATLAB displays the text cord at that location. With HitTest gear up to off, existing text cannot intercept whatever subsequent push button down events that occur over the text. This enables the paradigm'south push downwards role to execute.

HorizontalAlignment {left} | center | right

Horizontal alignment of text. This holding specifies the horizontal justification of the text cord. It determines where MATLAB places the string with regard to the bespeak specified by the Position holding. The following flick illustrates the alignment options.

See the Extent property for related information.

Interpreter {tex} | none

Interpret Tex instructions. This property controls whether MATLAB interprets certain characters in the String holding every bit Tex instructions (default) or displays all characters literally. See the Cord property for a list of supported Tex instructions.

Interruptible {on} | off

Callback routine intermission style. The Interruptible property controls whether a text callback routine can exist interrupted by subsequently invoked callback routines. Text objects have three backdrop that define callback routines: ButtonDownFcn, CreateFcn, and DeleteFcn. See the BusyAction belongings for data on how MATLAB executes callback routines.

LineStyle {-} | -- | : | -. | none

Edge line type. This holding determines the line style used to draw the edges of the text Extent. The available line styles are shown in the post-obit table.

Symbol
Line Way
-
solid line (default)
--
dashed line
:
dotted line
-.
dash-dot line
none
no line

For example, the following code draws a ruby rectangle wth a dotted line style around text that labels a plot.

  • text(3*pi/4,sin(3*pi/4),...      '\leftarrowsin(t) = .707',...      'EdgeColor','red',...      'LineWidth',two,...      'LineStyle',':');            

For additional features, see the following properties:

  • BackgroundColor -- Color of the rectangle's interior ( none by default)
  • EdgeColor -- Color of the rectangle'south border (none past default)
  • LineWidth -- Width of the rectangle's edge line (first set EdgeColor )
  • Margin -- Increase the size of the rectangle by adding a margin to the existing text extent rectangle
LineWidth scalar (points)

Width of line used to describe text extent rectangle. When you gear up the text EdgeColor property to a colour (the default is none), MATLAB displays a rectangle around the text Extent. Use the LineWidth property to specify the width of the rectangle border. For example, the following lawmaking draws a red rectangle around text that labels a plot and specifies a line width of iii points:

  • text(3*pi/4,sin(three*pi/4),... '\leftarrowsin(t) = .707',... 'EdgeColor','ruby',... 'LineWidth',3);            

For additional features, come across the post-obit backdrop:

  • BackgroundColor -- Colour of the rectangle's interior ( none by default)
  • EdgeColor -- Color of the rectangle's edge ( none past default)
  • LineStyle -- manner of the rectangle's edge line (starting time set EdgeColor )
  • Margin -- increase the size of the rectangle by adding a margin to the exsiting text extent rectangle
Margin scalar (pixels)

Distance between the text extent and the rectangle edge. When you specify a colour for the BackgroundColor or EdgeColor text properties, MATLAB draws a rectangle around the area defined by the text Extent plus the value specified past the Margin. For example, the following lawmaking displays a light light-green rectangle with a ten-pixel margin.

  • text(5*pi/4,sin(5*pi/4),...        ['sin(5*pi/4) = ',num2str(sin(5*pi/4))],...        'HorizontalAlignment','center',...         'BackgroundColor',[.7 .nine .seven],...        'Margin',x);            

For additional features, see the following backdrop:

  • BackgroundColor -- Color of the rectangle's interior (none by default)
  • EdgeColor -- Colour of the rectangle'southward edge (none by default)
  • LineStyle -- Style of the rectangle's edge line (starting time set EdgeColor )
  • LineWidth -- Width of the rectangle'southward border line (offset gear up EdgeColor )
Parent handle

Text object'due south parent. The handle of the text object'south parent object. The parent of a text object is the axes in which information technology is displayed. You can motility a text object to another axes by setting this holding to the handle of the new parent.

Position [x,y,[z]]

Location of text. A two- or three-element vector, [10 y [z]], that specifies the location of the text in three dimensions. If you omit the z value, it defaults to 0. All measurements are in units specified by the Units property. Initial value is [0 0 0].

Rotation scalar (default = 0)

Text orientation. This belongings determines the orientation of the text string. Specify values of rotation in degrees (positive angles cause counterclockwise rotation).

Selected on | {off}

Is object selected? When this property is set to on, MATLAB displays pick handles if the SelectionHighlight property is also set to on. You lot can, for example, define the ButtonDownFcn to set this belongings, assuasive users to select the object with the mouse.

SelectionHighlight {on} | off

Objects highlight when selected. When the Selected property is ready to on, MATLAB indicates the selected country past drawing four edge handles and four corner handles. When SelectionHighlight is ready to off, MATLAB does non draw the handles.

String string

The text string. Specify this property as a quoted string for unmarried-line strings, or as a cell array of strings, or a padded string matrix for multiline strings. MATLAB displays this string at the specified location. Vertical slash characters are not interpreted equally linebreaks in text strings, and are drawn equally office of the text string. See Mathematical Symbols, Greek Letters, and TeX Characters for an instance.

You tin also specify stream modifiers that command the font used. The starting time four modifiers are mutually exclusive. Still, you can use \fontname in combination with one of the other modifiers:

  • \bf -- bold font
  • \information technology -- italics font
  • \sl -- oblique font (rarely available)
  • \rm -- normal font
  • \fontname{fontname} -- specify the proper name of the font family to use.
  • \fontsize{fontsize} -- specify the font size in FontUnits.

Stream modifiers remain in event until the end of the string or only within the context defined by braces { }.

Specifying Subscript and Superscript Characters

The subscript character "_" and the superscript character "^" modify the graphic symbol or substring defined in braces immediately following.

To print the special characters used to ascertain the Tex strings when Interpreter is Tex, prefix them with the backslash "\" character: \\, \{, \} \_, \^.

See the instance in the text reference page for more information.

When Interpreter is set to none, no characters in the Cord are interpreted, and all are displayed when the text is drawn.

Tag string

User-specified object label. The Tag property provides a ways to identify graphics objects with a user-specified label. This is particularly useful when amalgam interactive graphics programs that would otherwise need to define object handles every bit global variables or pass them equally arguments betwixt callback routines. You tin define Tag as any string.

Type string (read but)

Class of graphics object. For text objects, Type is always the string 'text'.

Units pixels | normalized | inches |
centimeters | points | {information}

Units of measurement. This property specifies the units MATLAB uses to interpret the Extent and Position backdrop. All units are measured from the lower left corner of the axes plotbox.

  • Normalized units map the lower left corner of the rectangle defined past the axes to (0,0) and the upper correct corner to (1.0,1.0).
  • pixels, inches, centimeters, and points are absolute units (1 bespeak = 1/72 inch).
  • information refers to the information units of the parent axes.

If you change the value of Units, information technology is skillful practice to return it to its default value after completing your computation so as not to affect other functions that presume Units is set to the default value.

UserData matrix

User-specified data. Any data you want to acquaintance with the text object. MATLAB does not utilise this data, but you can access it using set and go.

UIContextMenu handle of a uicontextmenu object

Associate a context bill of fare with the text. Assign this property the handle of a uicontextmenu object created in the aforementioned effigy as the text. Use the uicontextmenu function to create the context menu. MATLAB displays the context menu whenever you correct-click over the text.

VerticalAlignment peak | cap | {middle} | baseline |
lesser

Vertical alignment of text. This property specifies the vertical justification of the text string. Information technology determines where MATLAB places the string with regard to the value of the Position property. The possible values mean

  • top -- Place the summit of the cord's Extent rectangle at the specified y-position.
  • cap -- Place the string then that the tiptop of a upper-case letter is at the specified y-position.
  • center -- Place the middle of the string at specified y-position.
  • baseline -- Identify font baseline at the specified y-position.
  • bottom -- Place the bottom of the string'south Extent rectangle at the specified y-position.

The following picture illustrates the alignment options.

Visible {on} | off

Text visibility. By default, all text is visible. When fix to off, the text is non visible, but still exists and you can query and set its properties.

 text textread

condonminat1970.blogspot.com

Source: http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/ref/text_props.html

0 Response to "How to Read Text File With Strings in Matlab"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel