100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
An explanation of Matlab tutorials €5,49
In winkelwagen

Handleiding

An explanation of Matlab tutorials

 105 keer bekeken  1 keer verkocht

The codes written during the matlab tutorial with a step by step explanation of what we are programming.

Voorbeeld 3 van de 20  pagina's

  • 11 december 2017
  • 20
  • 2017/2018
  • Handleiding
  • Onbekend
Alle documenten voor dit vak (2)
avatar-seller
wandykalk
Commands
Arrays and Matrices
Name = begin number:step width:end number
If there is no step width defined than it is automatically one

(begin number ⋯ end number)

Name = [number1, number2, number3; number4, number5, number6]

(number
number 1
4
number 2 number 3
number 5 number 6 )
size(Name)
number of rows , number of columns

Name = linspace( begin number, end number, number of steps)
(begin number ⋯ end number)
For example linspace (0,10,3)
(0 5 10)
If you don’t define a number of steps Matlab automatically assumes you want 100 steps

randn(n, m)
return a matrix n x m matrix of normally distributed random numbers

Saving and loading of documents
save (‘file_name’)
load (‘file_name.mat’)

Clearing Matlab
clear
this command clears the workspace

clc
this command clear the command window

Reading in file
Filename = ‘file.csv’

Name = cvsread(filename)
Read in comma separated file

Name(:,colomn number)
Prints that colomn

Name = num2string(filename)
Convert numerical data into a data string

dataNumber = datenum(date_strings, ‘yyyymmdd’)
Turns a date string into matlab internal date numbers

Dates = datastr(dataNumber, formatOut)
Format matlab internal date numbers into readable date numbers. The Formatout is the format you get the
dates in. If you for example use 24 as formatOut you get the dates in the following manner dd/mm/yyyy.
Instead of 24 you can also write ‘dd/mm/yyyy’ as FormatOut.

,New_vector = Name(:,column)
Write a certain statistic in own vector

 If you want to have a vector with the log returns you have to create a vector with only closing prices.
Then create a new vector by using the following formula
Log_returns = diff(log(closeprices))
Graphs
plot (Name)
plot vector Name in a graph. If the input is a matrix Matlab will plot each column.

plot( Namex, Namey)
Plot vector Namey in a graph and use Namex as the x-coordinates

 If you want to plot the log returns Namex is dateNumber(2:end), because you are taking difference the
first data point gets lost in the process. This will plot the returns against the matlab internal dates. If
you want readable date to be on the x-axis you have to use the following command
datetick (‘x’)

title(‘title_name’)
xlabel(“xlabel_name’)
ylabel(“ylabel_name’)
The commands above will add a title and/or labels fort the x-axis and y-axis

qqplot(name)
Displays a quantile-quantile plot of the quantiles of the sample data versus the theoretical quantiles values from
a normal distribution.

qqplot(name)
Displays a quantile-quantile plot of the quantiles of the sample data versus the theoretical quantiles values from
the distribution specified

Basic data analysis
length(name)
Gives the number of observations

sum(name)
Gives the sum of all the observations

prod(name)
Gives the product of all observations

min(name)
max(name)
Gives the minimum and maximum of all the observations

range(name)
Gives the difference between the minimum and maximum

mean(name)
median(name)
var(name)
std(name)
sqrt(var(name))
skewness(name)
kurtosis(name)

, Gives information about the distribution of the variable name

corrcoef(name)
Returns the matrix of correlation coefficients for name, where the columns of name represent random variables
and the rows represent observations.

quantile(name, probability)
Gives you the value that belongs to that probability. The chance that a value is smaller than the output is equal
to the probability you put in for input

sort(name)
Puts the values of the vector in the order from small to large

abs(name)
Makes all the values of the vector absolute

diff(name)
Takes the differences between the observations

Matrix Calculations
MatrixA= [number 1, number 2; number3, number 4]
MatrixB= [number 5, number 6; number7, number 8]
MatrixA .* MatrixB

(number 1∗number 5
number 3∗number 7
number 2∗number 6
number 4∗number 8 )
MatrixA * MatrixB
Multiplying matrices the same way as always (row times column)

MatrixA’
Gives the transpose of matrix A

Distributions
normalpdf(x, mu, sigma)
the chance you find value x in the normal distribution with mean mu and standard deviation sigma. If you put in
a vector your output will be a vector with probabilities. If mu and sigma are not defined Matlab assume mu to
be zero and sigma to be 1 (Z-distribution).

normalcdf(x, mu, sigma)
the chance you find value x or smaller in the normal distribution with mean mu and standard deviation sigma. If
you put in a vector your output will be a vector with probabilities. If mu and sigma are not defined Matlab
assume mu to be zero and sigma to be 1 (Z-distribution).

norminv(p, mu, sigma)
The output is the value for which the probability you will obtain that exact value or something smaller, is equal
to p.

normrnd(mu, sigma, number of rows, number of columns)
Creates a matrix with every cell containing a random variable of a normal distribution with mean mu and
standard deviation sigma.

[muhat,sigmahat,muci,sigmaci] = normfit(name)
Estimates the mu and sigma for each colomn of data. Also gives the confidence intervals (first a row with the
lower bound and then a row with upper bounds). If muci and sigmaci aren’t put in you only receive the
estimates as output

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 wandykalk. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

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

Is Stuvia te vertrouwen?

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

Afgelopen 30 dagen zijn er 53068 samenvattingen verkocht

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

Start met verkopen
€5,49  1x  verkocht
  • (0)
In winkelwagen
Toegevoegd