100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Summary Matlab ()

Puntuación
-
Vendido
6
Páginas
37
Subido en
23-02-2021
Escrito en
2019/2020

This document is an extensive summary of the introduction to Matlab. Everything is explained step by step, with examples.

Institución
Grado











Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
23 de febrero de 2021
Número de páginas
37
Escrito en
2019/2020
Tipo
Resumen

Temas

Vista previa del contenido

INTRODUCTION IN MATLAB
AND PROGRAMMING


Summary of Matlab


PRE-MASTER CEM/CME
ENGINEERING TECHNOLOGY




DOCUMENT NUMBER
01 – WILCO JONKER




2019-2020

,INTRODUCTION IN MATLAB AND PROGRAMMING
Pre-masters CEM / CME


1. Matlab Basics and Introduction:

Een paar commando’s om de ‘actuele stand van zaken’ op te vragen of te
beïnvloeden:

- format loose geeft meer ruimte tussen lijnen van uitkomst
- format compact geeft minder ruimte tussen lijnen van uitkomst
- format short geeft korte uitkomst
- format long geeft lange uitkomst

Format ‘short’ and ‘long’ can possibly complemented with G or E

- who opvragen van alle variabelen met een waarde
- size(x) geeft de afmetingen (aantal rijen, kolommen) van x
- clear x1 verwijder de variabele x1
- clear all verwijder de waarden van alle variabelen
- clc veegt het scherm schoon (idem: Clear Command Window)

clear verwijdert alles uit ‘Workspace’ en clc verwijdert alles uit ‘Command
Window’.

A(i,j) het element in de 'i' rij, 'j' kolom
A(:,j) 'j' kolom van A
A(i,:) 'i' rij van A


- Cancel the current execution of a command with “CTRL + C”
- Use the keys ↑ and ↓ to scroll through previous commands
- Use “CTRL + R” to command out a long block
- NaN = Not a Number


-------------------------------Array Commands------------------------------

find Finds indices of nonzero elements.
length Computers number of elements.
linspace Creates regularly spaced vector.
max Returns largest element.
min Returns smallest element.
prod Product of each column.
size Computes array size.
sort Sorts each column.
sum Sums each column.
Mod An integer m is a multiple applies to a certain integer n.

abs geeft de absolute waarde.
round geeft het dichtstbij gelegen geheel getal.
rank bepaalt de rang van een matrix.
size bepaalt het aantal rijen en kolommen van een matrix.
norm berekent de norm van een matrix of van een vector.
rand(m,n) geeft een (m x n)-matrix met randomgetallen, uniform verdeeld
tussen 0 en 1.
A’ geeft de getransponeerde van de matrix A.
A(:) zet alle kolommen van A onder elkaar in een vector.
ones(m,n) geeft een matrix van dimensie m x n met allemaal eentjes.
zeros(m,n) geeft een matrix van dimensie m x n met allemaal nullen.
fliplr(A) draait de matrix A om in de links/rechts richting.
flipud(A) draait de matrix A om in de onder/boven richting.

---------------------------------------------------------------------------

PAGE 1|36

,INTRODUCTION IN MATLAB AND PROGRAMMING
Pre-masters CEM / CME


2. Matlab Vectors:

We call a sequence of numbers a (row) vector.
The number of rows and columns determines the dimensions (‘size’) of the
matrix: a m-by-n matrix consists of m rows and n columns.


number vector matrix
5 [3 8 5] 3 8 4
[2 5 8 ]
7 5 5
1 2 3

1-by-1 1-by-3 4-by-3

- Difference between successive elements
vector = [initial value : difference : end value]
- Difference is equal to 1
vector = [initial value : end value]
- Linspace, equally distribute elements over the given interval
[initial value , end value] including endpoints (default: 100 elements)
Example: x = linspace(0,1,7) 7 elements between 0 to 1 equally distributed

- zeros(m,n) where all elements are 0
- ones(m,n) where all elements are 1
- rand(m,n) elements randomly chosen between 0 and 1
- randi(max_value,m,n) elements are integers from interval [1,max_value]

Examples:
zeros(1,8) één rij en 8 kolommen
zeros(2,8) twee rijen en 8 kolommen
randi(6,1,5) maximum waarde 6, 1 rij, 5 kolommen


COLUMN VECTOR AND ROW VECTOR
x= [1,2,3,4,5] or x= [1 2 3 4 5] row vector
x= [1;2;3;4;5] column vector
x= [1,2;3,4;5,6;7,8] command for row and column vector

Use always commas to put components of a vector function in a row vector,
because the use of spaces only is very ‘fault-sensitive’.

Difference rand en randi
rand: geeft getallen tussen 0 en 1
randi: geeft integers (gehele getallen)


--------------------------------- rand ------------------------------------

v= rand(20,1) geeft 20 getallen (tussen 0 en 1) en 1 column

v= rand(10,2) geeft 10 getallen (tussen 0 en 1) en 2 columns


--------------------------------- randi -----------------------------------

v= randi(10,1) geeft 1 getal tussen 0 en 10

v= randi(30,2) geeft 4 getallen (matrix) tussen 0 en 30



PAGE 2|36

, INTRODUCTION IN MATLAB AND PROGRAMMING
Pre-masters CEM / CME

v= randi(30,1,10) geeft 1 row, 10 columns met getalen tussen 0 en 30
dus 10 getallen tussen 0 en 30

v= randi(30,12,1) geeft 12 rows, 1 column met getalen tussen 0 en 30

v= randi(20,2,10) geeft 2 rows, 10 columns met getalen tussen 0 en 20

v= randi([-10,10],1,20) geeft 1 row, 10 columns met getallen tussen -10 en
10 gebruik blokhaken [ ] en ,


------------------------- max/min and location/index ----------------------
v= [7 8 3 1 5 7 6]

- Find the maximum value of vector v
maximum= max(v)

- Find the minimum value of vector v
minimum= min(v)

- Calculate the average of vector v
average= mean(v)

- Determine the greatest value of vector v and the corresponding index
[maximum,location]= max(v)

- Determine ONLY the location of the greatest value
location= find(v == max(v))

- How many elements of v are smaller than 5 and give their index.
a= find(v<5);
smaller= length(a)

- How many elements of v are smaller than 5.
smaller= sum(v<5)


------------------------- Vector odd and even -----------------------------
v= [1:25]

INDEX
- Delete all elements with an even index
v_delete_even = v(1:2:end)

- Delete all elements with an odd index
v_delete_odd = v(2:2:end)

ELEMENTS
- Delete all even elements (show all odd elements)
v_delete_even_elements = v(mod(v,2)~=0)

- Delete all odd elements (show all even elements)
v_delete_odd_elements = v(mod(v,2)==0)


------------------------- Manipulate or expand vector ---------------------

v= [-3.5 3.5 4.0 5.0 -3.5 0 -15.0]

- Replace the first three elements for [-2,7,-4]
v(1:3) = [-2 7 -4]


PAGE 3|36
Gratis
Accede al documento completo:
Descarga

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
WilcoJonker

Conoce al vendedor

Seller avatar
WilcoJonker Universiteit Twente
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
45
Miembro desde
4 año
Número de seguidores
21
Documentos
13
Última venta
3 meses hace

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes