• Nie Znaleziono Wyników

II Year Electronics and Computer Engineering, FoE, WUST

N/A
N/A
Protected

Academic year: 2021

Share "II Year Electronics and Computer Engineering, FoE, WUST"

Copied!
2
0
0

Pełen tekst

(1)

Scientific & Engineering Programming

II Year Electronics and Computer Engineering, FoE, WUST

Laboratory Class 9 – Matlab basics 2

The scope

To get familiar with Matlab interfaces, to define functions, conditionals, and loops, to learn graph plotting.

Prerequisites

Before the classes you should know, how to:

• define Matlab functions, compute their values,

• define conditionals,

• generate function plots.

Tasks

1. Find the roots of the polynomials (roots):

(a) x 2 + x − 6, (b) x 3 + 3x 2 − 4,

(c) x 4 − 2x 3 + x 2 − 8x − 12, (d) x 5 − 3x 4 − 9x 3 + 31x 2 − 36.

2. Define the functions f (x) = x

4

x +1

3

, g(x, y) = p

25 − x 2 − y 2 , and h(x, y) = x + 2y xy



. Calcu- late f (5), g(1, 2), and h(f (3), 2).

3. Define the function f (x) which for its scalar argument returns absolute value of sine of it.

4. Define the function f (x) which for its scalar argument returns value of sine of it when it is positive, and zero otherwise.

5. Define the function mysing(x) which returns -1, 0, or 1, according as x is less than, equal to, or greater than 0.

6. Define the function mysum(x) which for its argument being a vector returns the sum of vector elements.

7. Define the function sumP ositive(x) which for its argument being a vector returns the sum of vector positive elements.

8. Define the function sumAll(x) which for its argument being a vector returns two separate values: the sums of positive, and the sum of negative vector elements.

9. Define the function mypoly(x, c) which for its arguments: a scalar x and a vector (c 1 , c 2 , c 3 , . . .) evaluate a polynomial c 0 + c 1 x + c 2 x 2 + c 3 x 3 + . . . and returns its value.

1

(2)

Scientific & Engineering Programming, II Year EaCE, FoE, WrUST 2

10. Define the function gcd(m, n) that implements the Euclidean algorithm for finding the great- est common divisor of m and n.

11. Plot functions defined in the tasks 2–5.

Cytaty

Powiązane dokumenty

The equality of vectors, the operations of vector multiplication on a number, the sum, subtraction and scalar product of vectors that is performed in the component

The points 0 and oo break up dQ. into two Jordan curves which are denoted T- and T+. Let T be a Jordan curve with endpoints 0 and oo all of who other points belong to fl. It

Exercise the Five Minute Hands-On intro from Welcome to Wolfram Cloud section (Quick Links).. Exercise the Some Things to Try from Welcome to Wolfram

To get familiar with Mathematica interfaces, to perform basic calculations with vectors and ma-

Prepare the simulations environment allowing for results visualization (time plots, animation of the car represented by two wheels: front (turnable) and rear ∗ ). Interpret the

To get familiar with the methodology of dynamical systems simulations in Matlab, methods for results visualization and

To get familiar with the methodology of dynamical systems simulations in Simulink, methods for results visualization and

The ethical judgment is also influenced by the organizational factors creating a pres- sure on an individual. The influence of significant others, i.e. other persons being members