Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may need to fill your matrix with default valued lines in order to create it. The typical approach to preallocating a matrix of objects of size <code>N</code> would be to simply assign an object to the last element in the matrix.</p> <pre><code>M(N,N)=imline(gca,[NaN NaN],[NaN NaN]); %# set non-displayable vals for x and y </code></pre> <p><strong>NOTE, the line above will not work with <code>imline</code></strong> as it will call the default constructor for each of the other N*N-1 imline objects in the matrix and a call of <code>imline</code> with no arguments forces user interaction with the current axis. </p> <p>My advice (if you are pre-allocating) is to define all the default lines <em>explicitly</em> in the matrix:</p> <pre><code>for k=1:N*N M(k)=imline(gca,[NaN NaN],[NaN NaN]); end %# Reshape (if necessary) M = reshape(M,[N N]); </code></pre> <p>Alternatively, you could let Matlab fill the array for you. If you find that you will need this code often, derive a new class from <code>imline</code>. The following example shows the very least that would need to happen. It merely defines a constructor. This example allows you to pass optional arguments to <code>imline</code> as well. If no arguments are specified, the <code>imline</code> object is created with position values as above. </p> <pre><code>classdef myimline&lt;imline methods function obj = myimline(varargin) if isempty(varargin) varargin = {gca,[NaN NaN],[NaN NaN]}; end obj = obj@imline(varargin{:}); end end end </code></pre> <p>Example usage:</p> <pre><code>%# Generate a 100 element array of `imline` objects, %# but define the last one explicitly mat(100)=myimline(gca,[0 1],[0 1]); </code></pre> <p>The last <code>myimline</code> object in the array has points specified as in the assignment, but the rest of the elements have the default position values <code>[NaN NaN]</code> as above. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload