Tutorial by Examples

The MATLAB Profiler is a tool for software profiling of MATLAB code. Using the Profiler, it is possible to obtain a visual representation of both execution time and memory consumption. Running the Profiler can be done in two ways: Clicking the "Run and Time" button in the MATLAB GUI...
Python 3.x3.3 Use yield from if you want to yield all values from another iterable: def foob(x): yield from range(x * 2) yield from range(2) list(foob(5)) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1] This works with generators as well. def fibto(n): a, b = 1, 1 while True: ...
One might want to group their data by the runs of a variable and perform some sort of analysis. Consider the following simple dataset: (dat <- data.frame(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1 1 1 # 2 1 2 # 3 2 3 # 4 2 4 # 5 2 5 # 6 1 6 The variable x has three runs: a run of l...
Given this setup code: var dict = new Dictionary<int, string>() { { 1, "First" }, { 2, "Second" }, { 3, "Third" } }; You may want to read the value for the entry with key 1. If key doesn't exist getting a value will throw KeyNotFoundException,...
The following code is for iOS 8 and lower for creating a login alert. // Create the UIAlertView var loginAlertView = new UIAlertView(title, message, null, cancelTitle, okTitle); // Setting the AlertViewStyle to UIAlertViewStyle.LoginAndPasswordInput loginAlertView.AlertViewStyle = UIAlertViewS...
The module cmath includes additional functions to use complex numbers. import cmath This module can calculate the phase of a complex number, in radians: z = 2+3j # A complex number cmath.phase(z) # 0.982793723247329 It allows the conversion between the cartesian (rectangular) and polar repr...
Python has built-in support for complex arithmetic. The imaginary unit is denoted by j: z = 2+3j # A complex number w = 1-7j # Another complex number Complex numbers can be summed, subtracted, multiplied, divided and exponentiated: z + w # (3-4j) z - w # (1+10j) z * w # (23-11j) z / w # (...
To install Eclipse, go to the Eclipse Downloads Web page where there is usually a direct link to download the latest version of Eclipse. Starting Eclipse Mars (version 4.5), an installer can be downloaded which guides you through the installation procedure, as opposed to downloading the whole instal...
This a basic example aimed at new users. It does not focus on explaining the difference between char and cellstring. It might happen that you want to get rid of the ' in your strings, although you never added them. In fact, those are artifacts that the command window uses to distinguish between ...
Option Explicit Sub LoopAllSheets() Dim sht As Excel.Worksheet ' declare an array of type String without committing to maximum number of members Dim sht_Name() As String Dim i As Integer ' get the number of worksheets in Active Workbook , and put it as the maximum number of members in t...
Shift Use .shift to remove the first item of an array. For example: var array = [1, 2, 3, 4]; array.shift(); array results in: [2, 3, 4] Pop Further .pop is used to remove the last item from an array. For example: var array = [1, 2, 3]; array.pop(); array results in: [1, 2] Bot...
.reverse is used to reverse the order of items inside an array. Example for .reverse: [1, 2, 3, 4].reverse(); Results in: [4, 3, 2, 1] Note: Please note that .reverse(Array.prototype.reverse) will reverse the array in place. Instead of returning a reversed copy, it will return the same ar...
function Invoke-MyCmdlet { [CmdletBinding(SupportsShouldProcess = $true)] param() # ... }
if ($PSCmdlet.ShouldProcess("Target of action")) { # Do the thing } When using -WhatIf: What if: Performing the action "Invoke-MyCmdlet" on target "Target of action" When using -Confirm: Are you sure you want to perform this action? Performing operation &qu...
class Person { [string] $FirstName [string] $LastName [string] Greeting() { return "Greetings, {0} {1}!" -f $this.FirstName, $this.LastName } } $x = [Person]::new() $x.FirstName = "Jane" $x.LastName = "Doe" $greeting = $x.Greeting() #...
5.0 In PowerShell 5.0+ you can list available constructors by calling the static new-method without parentheses. PS> [DateTime]::new OverloadDefinitions ------------------- datetime new(long ticks) datetime new(long ticks, System.DateTimeKind kind) datetime new(int year, int month, int d...
class Person { [string] $Name [int] $Age Person([string] $Name) { $this.Name = $Name } Person([string] $Name, [int]$Age) { $this.Name = $Name $this.Age = $Age } }
Vector size is simply the number of elements in the vector: Current vector size is queried by size() member function. Convenience empty() function returns true if size is 0: vector<int> v = { 1, 2, 3 }; // size is 3 const vector<int>::size_type size = v.size(); cout << size...
Declaration-site variance can be thought of as declaration of use-site variance once and for all the use-sites. class Consumer<in T> { fun consume(t: T) { ... } } fun charSequencesConsumer() : Consumer<CharSequence>() = ... val stringConsumer : Consumer<String> = cha...
Use-site variance is similar to Java wildcards: Out-projection: val takeList : MutableList<out SomeType> = ... // Java: List<? extends SomeType> val takenValue : SomeType = takeList[0] // OK, since upper bound is SomeType takeList.add(takenValue) // Error, lower bound for...

Page 139 of 1336