Matlab Sheet 2 Arrays









matlab-basic-functions-reference.pdf

Create vector of n equally spaced values logspace(ab
matlab basic functions reference


APUNTES MATLAB

logspace - Logarithmically spaced vector. freqspace - Frequency spacing for frequency response. meshgrid - X and Y arrays for 3-D plots.
APUNTES MATLAB


MATLAB Commands and Functions

Matrix Commands for Solving Linear Equations / 6 Lists all MATLAB files in the current directory. wklread ... Creates logarithmically spaced vector.
MatlabCommands


MATLAB® Basic Functions Reference

mathworks.com/help/matlab. MATLAB® Basic Functions Reference Defining and Changing Array Variables ... Create vector of n logarithmically spaced.
matlab basic functions reference





INTRODUCTION TO MATLAB FOR ENGINEERING STUDENTS

4 Introduction to programming in MATLAB log10(x) Common logarithm conj(x) ... generates a row vector y of 100 points linearly spaced between and ...
introduction to matlab


PROGRAMACI´ON EN MATLAB

3 oct de 2014 vamente la estructura de datos central de MATLAB: el array. ... cuada para introducir el vector—también es capaz de leer matrices.
apuntesMATLAB


Untitled

Matlab. • Cosa è Matlab. • L'ambiente a riga di comando Information about MATLAB and The MathWorks. ... Logarithmically spaced vector.
Matlab.Introduzione


matlab-help-text asec acsc cot acot exp log logic sqrt abs angle conj

Logarithmically spaced vector. meshgrid. - X and Y arrays for 3-D plots. : - Regularly spaced vector and index into matrix. Basic array information.
Matlab help text





Matlab Sheet 2 Arrays

Matlab Sheet 2 Solution. Matlab Sheet 2. Arrays. 1. a. Create the vector x having 50 logarithmically spaced values starting at. 10 and ending at 1000.
Matlab Sheet solution


Programing the Finite Element Method with Matlab

3 oct de 2002 following Matlab code which sets the row and column of a matrix A to zero ... Logarithmically spaced vector. meshgrid.
matlab fem


217065 Matlab Sheet 2 Arrays Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 1 of 32 Matlab Sheet 2 Solution

Matlab Sheet 2

Arrays

1. a. Create the vector x having 50 logarithmically spaced values starting at

10 and ending at 1000.

b. Create the vector x having 20 logarithmically spaced values starting at

10 and ending at 1000.

The m-file:

x1=logspace(1,3) x2=logspace(1,3,20)

2. Create a row vector that has the following elements: 8, 10/4, 12ൈ1.4, 51,

tan 85°,ξʹ͸ , and 0.15.

The m-file:

row=[8 10/4 12*1.4 51 tand(85) sqrt(26) 0.15]

In Command Window:

row =

8 2.5 16.8 51 11.43 5.099 0.15

3. Create a row vector in which the first element is 1 and the last element is 43,

The m-file:

row=1:6:43

In Command Window:

row =

1 7 13 19 25 31 37 43

Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 2 of 32 Matlab Sheet 2 Solution

4. Use a single command to create a row vector (assign it to a variable named b)

with 11 elements, such that b = 0 2 4 6 8 10 12 9 6 3 0

Do not type the vector explicitly.

The m-file:

b=[0:2:12 9:-3:0]

In Command Window:

b =

0 2 4 6 8 10 12 9 6 3 0

5. Create two row vectors: a=2:3:17 and b=3:4:15. Then, by only using the name

of the vectors (a and b), create a row vector c that is made from the elements of a followed by the elements of b.

The m-file:

a=2:3:17; b=3:4:15; c=[a,b]

In Command Window:

c =

2 5 8 11 14 17 3 7 11 15

name of the vectors (a and b), create a column vector c that is made from the elements of a followed by the elements of b.

The m-file:

a=[2:3:17]'; b=[3:4:15]'; c=[a;b]

In Command Window:

c = 2 5 8 11 Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 3 of 32 Matlab Sheet 2 Solution 14 17 3 7 11 15

7. A Type this matrix in MATLAB and use MATLAB to carry out the following

Instructions:

a. Create a vector v consisting of the elements in the second column of A. b. Create a vector w consisting of the elements in the second row of A.

The m-file:

A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1];

v = A(:,2) w = A(2,:)

In Command Window:

v = 7 9 13 5 w = -5 9 10 2 Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 4 of 32 Matlab Sheet 2 Solution

8. Create the following matrix by using vector notation for creating vectors with

constant spacing and/or the linspace command. Do not type individual elements explicitly.

The m-file:

A=[130:-20:10; linspace(1,12,7); 12:10:72]

In Command Window:

A= A =

130 110 90 70 50 30 10

1. 2.8333 4.6667 6.5000 8.3333 10.1667 12.0000

12 22 32 42 52 62 72

9. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:

%alternative C = [linspace(7,7,5); linspace(7,7,5)]

C=7*ones(2,5)

In Command Window:

C =

7 7 7 7 7

7 7 7 7 7

Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 5 of 32 Matlab Sheet 2 Solution

10. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:

D=[zeros(3,4) [8:-1:6]']

In Command Window:

D =

0 0 0 0 8

0 0 0 0 7

0 0 0 0 6

11. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:

Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 1 of 32 Matlab Sheet 2 Solution

Matlab Sheet 2

Arrays

1. a. Create the vector x having 50 logarithmically spaced values starting at

10 and ending at 1000.

b. Create the vector x having 20 logarithmically spaced values starting at

10 and ending at 1000.

The m-file:

x1=logspace(1,3) x2=logspace(1,3,20)

2. Create a row vector that has the following elements: 8, 10/4, 12ൈ1.4, 51,

tan 85°,ξʹ͸ , and 0.15.

The m-file:

row=[8 10/4 12*1.4 51 tand(85) sqrt(26) 0.15]

In Command Window:

row =

8 2.5 16.8 51 11.43 5.099 0.15

3. Create a row vector in which the first element is 1 and the last element is 43,

The m-file:

row=1:6:43

In Command Window:

row =

1 7 13 19 25 31 37 43

Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 2 of 32 Matlab Sheet 2 Solution

4. Use a single command to create a row vector (assign it to a variable named b)

with 11 elements, such that b = 0 2 4 6 8 10 12 9 6 3 0

Do not type the vector explicitly.

The m-file:

b=[0:2:12 9:-3:0]

In Command Window:

b =

0 2 4 6 8 10 12 9 6 3 0

5. Create two row vectors: a=2:3:17 and b=3:4:15. Then, by only using the name

of the vectors (a and b), create a row vector c that is made from the elements of a followed by the elements of b.

The m-file:

a=2:3:17; b=3:4:15; c=[a,b]

In Command Window:

c =

2 5 8 11 14 17 3 7 11 15

name of the vectors (a and b), create a column vector c that is made from the elements of a followed by the elements of b.

The m-file:

a=[2:3:17]'; b=[3:4:15]'; c=[a;b]

In Command Window:

c = 2 5 8 11 Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 3 of 32 Matlab Sheet 2 Solution 14 17 3 7 11 15

7. A Type this matrix in MATLAB and use MATLAB to carry out the following

Instructions:

a. Create a vector v consisting of the elements in the second column of A. b. Create a vector w consisting of the elements in the second row of A.

The m-file:

A = [3,7,-4,12;-5,9,10,2;6,13,8,11;15,5,4,1];

v = A(:,2) w = A(2,:)

In Command Window:

v = 7 9 13 5 w = -5 9 10 2 Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 4 of 32 Matlab Sheet 2 Solution

8. Create the following matrix by using vector notation for creating vectors with

constant spacing and/or the linspace command. Do not type individual elements explicitly.

The m-file:

A=[130:-20:10; linspace(1,12,7); 12:10:72]

In Command Window:

A= A =

130 110 90 70 50 30 10

1. 2.8333 4.6667 6.5000 8.3333 10.1667 12.0000

12 22 32 42 52 62 72

9. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:

%alternative C = [linspace(7,7,5); linspace(7,7,5)]

C=7*ones(2,5)

In Command Window:

C =

7 7 7 7 7

7 7 7 7 7

Faculty of Engineering Spring 2017 Mechanical Engineering Department Dr./ Ahmed Nagib Elmekawy 5 of 32 Matlab Sheet 2 Solution

10. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:

D=[zeros(3,4) [8:-1:6]']

In Command Window:

D =

0 0 0 0 8

0 0 0 0 7

0 0 0 0 6

11. Create the following matrix by typing one command. Do not type individual

elements explicitly.

The m-file:


  1. logarithmically spaced vector matlab
  2. log spaced vector matlab