Deprecated: Optional parameter $args declared before required parameter $parser is implicitly treated as a required parameter in /var/www/vhosts/rave.gatech.edu/httpdocs/help/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php on line 70

Deprecated: Optional parameter $prefix declared before required parameter $code is implicitly treated as a required parameter in /var/www/vhosts/rave.gatech.edu/httpdocs/help/languages/Language.php on line 4270

Warning: Private methods cannot be final as they are never overridden by other classes in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/actions/Action.php on line 67

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/json/FormatJson.php on line 397

Deprecated: Return type of ResultWrapper::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/db/DatabaseUtility.php on line 174

Deprecated: Return type of ResultWrapper::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/db/DatabaseUtility.php on line 192

Deprecated: Return type of ResultWrapper::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/db/DatabaseUtility.php on line 185

Deprecated: Return type of ResultWrapper::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/db/DatabaseUtility.php on line 202

Deprecated: Return type of ResultWrapper::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/db/DatabaseUtility.php on line 163

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/rave.gatech.edu/httpdocs/help/languages/LanguageConverter.php on line 703

Warning: Trying to access array offset on value of type bool in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/libs/IPSet.php on line 243

Warning: Trying to access array offset on value of type bool in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/libs/IPSet.php on line 246

Warning: Trying to access array offset on value of type bool in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/libs/IPSet.php on line 243

Warning: Trying to access array offset on value of type bool in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/libs/IPSet.php on line 246

Deprecated: Optional parameter $label declared before required parameter $alt is implicitly treated as a required parameter in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/Linker.php on line 730

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 104

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 104

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 105

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 105

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 106

Warning: Trying to access array offset on value of type null in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php on line 106

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/skins/SkinTemplate.php on line 313

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/languages/Language.php on line 2104

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/languages/Language.php on line 2104

Deprecated: Optional parameter $attribs declared before required parameter $contents is implicitly treated as a required parameter in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/Xml.php on line 131
Review of MATLAB Syntax - Rave Documentation

Review of MATLAB Syntax

From Rave Documentation
Jump to: navigation, search

Introduction

Before attempting to code a MATLAB plugin, you should be VERY familiar with the 4 basic MATLAB data types: numerical arrays, strings, cell arrays, and structures. If you are coding a workspace object, you should also be VERY familiar with graphics object handles, properties, and the set/get command. You should also understand how to create fast graphics (i.e. ones that will render quickly). The sections below briefly summarize some of these points, but they are not a substitute for real experience.

guidata and the handles structure

Almost all data tracked by rave that is NOT particular to one graph is stored in a variable named “handles”. Unfortunately this is the same name as the concept of the handle of a graphics object, but it is also the default name MATLAB uses for this variable and I didn’t change it. (For consistency, you shouldn’t either). handles is a structure, which you can think of as a folder that holds other variables (many of which are themselves also structures). The handles structure is special in that it is stored and retrieved using the “guidata” function, which allows it to easily be shared by all functions in rave. (A better way to say this is that there is a single special variable that can be stored/retrieved using the guidata function, and in this case that variable is a structure which we will always name “handles”.)

There is always only ONE guidata variable that is shared by EVERY object/callback of a single figure (i.e. window) This variable is retrieved using the syntax handles=guidata(src); where “src” is the handle of any object in the figure. Regardless of what the “src” handle is, you will always get the same handles structure as you’d get using any other “src” in the same figure. IMPORTANTLY, this means that handles is only shared among callbacks that originate from the main rave window. Callbacks from popup windows will have their own guidata, and must access the main handles structure using another method (described elsewhere).

Any time you make changes to the handles structure, you must also store the updated results, also done using the guidata function, but with the syntax guidata(src,handles); (note in either case, src is always the first input to guidata.) Again, it does not matter what “src” is – this function call sets the guidata for EVERY object in the figure.

What are the implications of all this? Simply that most functions in rave do not have inputs and outputs in the traditional sense. Instead, each function takes a handle (src) as an input, then uses handles=guidata(src) to retrieve ALL your data. Then the function modifies handles as necessary, and stores the results using guidata(src,handles).

Consequently, handles=guidata(src) is the first line of almost every function in rave. And guidata(src,handles) is the last line of almost every function (the exception being those functions that don’t actually change handles.

Structures and Cell Arrays

In MATLAB, a structure contains “fields,” each of which can be thought of as a new variable. Fields are accessed by typing the name of the structure, a period, then the name of the field. For example, the statement handles.index=5 creates a field named “index” in the structure “handles” and gives this field the value 5. Since 5 is a number, handles.index is effectively a double precision array with dimension 1x1. Depending on what is to the right of the equals sign, handles.index could also have been made into a string, cell array, or other class of numeric array. If you want handles.index to itself be a structure, just append another period and field name. For example, handles.index.data=10.

Now, if handles.index is an array, you can directly reference into it using parentheses. For example, handles.index=[2 4 6 8], then handles.index(3) will return “6”. Similarly, if handles.index is a cell array, you can reference into it using braces.

As with any cell array in MATLAB, a structure field that is a cell array can contain other (nested) cell arrays. You can index into nested cell arrays by simply appending more and more curly braces, and (if necessary) a final reference into a numerical array in parentheses. (You can ALWAYS only have 1 parenthetical reference and it must be the last reference).

For example, the line mycolumn=handles.alldata{1}{3}(:,5); Tells you that handles.alldata is a cell array that contains at least 1 entry, which must also be a cell array (since the next reference is also to a cell) that in turn contains at least 3 elements. The 3rd element of THAT cell array must be a numerical matrix, since the next reference is in parentheses (instead of braces) , and it must contain at least 5 columns, since the index references the 5th column. Thus, mycolumn is the 5th column of the 3rd cell of the 1st cell of handles.alldata. If all of that made sense to you, you’ll do just fine. If instead you said “huh?” you should probably read the MATLAB help files for structures and cell arrays and practice using them before you try coding for rave. Note there are also more complex references possible where the fields themselves have dimensions, things like handles.alldata(5).names{3}, but rave (I think) never uses these.


Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/profiler/SectionProfiler.php:104) in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/WebResponse.php on line 37