100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
Samenvatting 5th edition Matlab programming €9,66
In winkelwagen

Samenvatting

Samenvatting 5th edition Matlab programming

 2 keer bekeken  0 keer verkocht

Dit document is een samenvatting van het boek MATLAB: A Practical Introduction to Programming and Problem Solving, 5th Edition. Over de hoofdstukken 1 t/m 5 & 8.2. Het is gemaakt voor het vak Introduction to Matlab Programming for Behavioural Scientists. Voor de master Neuroeconomics.

Voorbeeld 4 van de 42  pagina's

  • Nee
  • Hoofdstuk 1 t/m 5 en 8.2
  • 10 december 2024
  • 42
  • 2024/2025
  • Samenvatting
book image

Titel boek:

Auteur(s):

  • Uitgave:
  • ISBN:
  • Druk:
Alle documenten voor dit vak (1)
avatar-seller
pleunvanderzand
Chapter 1
doc: then you find everything to look up
not use for expressions: ans, i, j

carefully look what you are doing:
>> mynum = 6 + 1
mynum = 7
>> mynum + 3
ans = 10
>> mynum
mynum =7

initializing a variable: assigning it a starting or initial value when the variable is created.
incrementing: adding to a variable
decrementing: subtracting from the value

naming a variable: max 63 characters (namelengthmax) name must start with a letter after
that it can contain letters, digits and the underscore. There is a difference between upper-
and lowercase letters. you can not use:
- who shows variables that have been defined in this Command Window (this just
shows the names of the variables)
- whos shows variables that have been defined in this Command Window (this shows
more information on the variables, similar to what is in the Workspace Window) it
shows the type(class) as well as the number of bytes used to store the value.
- clearvars clears out all variables so they no longer exist
Clearvars variablename → clears only that variable
- clear same as clearvars but also clears out functions

floating-point numbers: numbers with decimal places. “Double precision” means the number
is stored using more bits (64 bits) than “single precision” (32 bits). This allows (double):
• Higher precision (more accurate representation of decimal places).
• Larger range of numbers (can represent extremely large or small values).

int8 uses eight bits altogether to store the integer and its sign. As one bit is used for the
sign, this means that seven bits are used to store actual numbers (0s or 1s).
uint8 unsigned integer, the sign is not stored, meaning that the integer can only be positive
(or 0).
The larger the number in the type name, the larger the number that can be stored

Char is used to store either single characters (e.g., ‘x’) or character vectors, which are
sequences of characters (e.g., ‘cat’).
String is used to store strings (e.g., “hello”). Strings are enclosed in double quotes
logical is used to store true/false values

format long/short you can choose if you want long (many decimal numbers) ore short
format loose/compact when you use loose there are more witregels tussen antwoord

,ellipsis … use when you want to continue
3 + 5 ...
+ 2 ...
+1
ans =
11

>> 2 * 10^4 is the same as >>2e4

associativity: then the expression are evaluated from left to right and not by the standard
rules of * and + etc.

>> help elfun → elementary functions
>>plus(2,5)
ans =
7


→ you can use this when it is no
problem that they will be override




Random numbers in matlab are pseudorandom—they are not truly random because there
is a process that determines the next value each time.

rand used to generate uniformly distributed random real numbers; calling it generates one
random real number in the open interval (0,1).
>>rand*10 → result in open interval (0,10)
The rng function sets the initial seed. several ways in which it can be called:
>> rng('shuffle') → uses the current date and time that are returned from the built-in clock
function to set the seed
>> rng(intseed) → set the seed to the default value used when MATLAB starts up
>> rng('default')

generate a random real number in the range low to high
>> low = 3;
>> high = 5;
>> rand *(high low) + low
would generate a random real number in the open interval (3, 5)

randn is used to generate normally distributed random (around the mean) real numbers
randi(4) returns a random integer (whole number) in the range from 1 to 4. A range can also
be passed, for example, randi([3, 6]) between 3 and 6

One reason for using an integer type for a variable is to save space in memory.

,or operator has two logical expressions as operands. The result is true if either or both of the
operands are true, and false only if both operands are false.
and expression is true only if both operands are true; it is false if either or both are false.

|| and && operators in MATLAB are examples of operators that are known as short-circuit
operators. the first part, 2 < 4, is true so the entire expression is true; the second part ‘a’ ==
‘c’ would not be evaluated.
>> 2 < 4 || ‘a’ == ‘c’

xor It returns logical true if one (and only one) of the arguments is true
>> xor(3<5, ‘a’ > ‘c’)
ans =
1
>>xor(3<5, ‘a’ < ‘c’) → both true so it is false with xor
ans =
0

true = 1 Logical(1) and false = 0 logical(0)

>> 3 < 5
ans =
logical
1

>> logresult = 5 < 7
logresult =
1
>> logresult + 3
ans =
4

, Direction of Division:
• / divides the left operand by the right operand: A / B = A * B^-1.
• \ divides the right operand by the left operand: A \ B = A^-1 * B.
Matrix Applications:
• / solves for X in X * B = A.
• \ solves for X in A * X = B.
Use Cases:
• Use / when you need right division.
• Use \ to solve linear systems efficiently.

uint8 stores 2^8 or 256 integers, ranging from 0 to 255. The range of values that can be
stored in int8, however, is from -128 to +127.
>> intmin(‘int8’)
ans =
-128
>>intmax(‘int8’)
ans =
127

cast can cast a variable to a particular type, for example cast a variable to the same type
using ‘like’.




can aslo be used to convert a character to its equivalent numerical value ‘a’ to his number

this stores the double value 97 in the variable numequiv
shows that ‘a’ is the 98th character in the character encoding

char does it the other way around

use it together →




rem how many times goes it in the number and what is the result 5 goes 2 times in 13 and
remainder is 3
>> rem(13,5)
ans = 3

Voordelen van het kopen van samenvattingen bij Stuvia op een rij:

Verzekerd van kwaliteit door reviews

Verzekerd van kwaliteit door reviews

Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!

Snel en makkelijk kopen

Snel en makkelijk kopen

Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.

Focus op de essentie

Focus op de essentie

Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper pleunvanderzand. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor €9,66. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 52510 samenvattingen verkocht

Opgericht in 2010, al 14 jaar dé plek om samenvattingen te kopen

Start met verkopen
€9,66
  • (0)
In winkelwagen
Toegevoegd