Tutorial by Examples: c

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...
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 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 # (...
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...
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...
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...
MATLAB code can be saved in m-files to be reused. m-files have the .m extension which is automatically associated with MATLAB. An m-file can contain either a script or functions. Scripts Scripts are simply program files that execute a series of MATLAB commands in a predefined order. Scripts do no...
You can declare properties in interfaces. Since an interface cannot have state you can only declare a property as abstract or by providing default implementation for the accessors. interface MyInterface { val property: Int // abstract val propertyWithImplementation: String g...
Reading a file line by line public class Main { public static void main(String[] args) { try { Scanner scanner = new Scanner(new File("example.txt")); while(scanner.hasNextLine()) { String line = scanner.nextLine(); ...
One std::vector can be append to another by using the member function insert(): std::vector<int> a = {0, 1, 2, 3, 4}; std::vector<int> b = {5, 6, 7, 8, 9}; a.insert(a.end(), b.begin(), b.end()); However, this solution fails if you try to append a vector to itself, because the sta...
DT[where, select|update|do, by] syntax is used to work with columns of a data.table. The "where" part is the i argument The "select|update|do" part is the j argument These two arguments are usually passed by position instead of by name. Our example data below is mtcars =...
<PROJECT_ROOT>\app\build.gradle is specific for app module. <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. If you use another module in your project, as a local library you would have another...
First install the .NET Core SDK by going through the installation instructions for the platform of your choice: Windows OSX Linux Docker After the installation has completed, open a command prompt, or terminal window. Create a new directory with mkdir hello_world and change into the ne...

Page 85 of 826