Ejercicios Matlab 1
Ejercicios Matlab 1
Problem 1
Using the MATLAB built-in functions(e.g. zeros...), Create the following matrix
0 0 0 1 1
0 0 0 1 1
1 0 0 0 0
A=
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Problem 2
Write the MATLAB command for the following line, compute Y.
Problem 3
Given MATLAB commands to plot, on the same figure, the two functions:
f = 3t2 + 2t − 0.5
g = 2tcos(t)
Where the variable t varies from 0 to 10 with step 0.5.
1. Draw the function f in blue line with point style circle,and the function g in red line with
each point as star.
2. Give title to your graph and label the axes.
Problem 4
Write a user-defined MATLAB Function for the following math function:
The input to the function are x and y, the output is Z. Write the function such that x can
be a vector.
1. Use the function to calculate Z(−3, 4) and Z(5, −7).
1
Introduction to Matlab
UCM-CompuMate Practice 1 March 14, 2019
2. Use the plot3 function to make a 3D plot of the function Z(x, y) for −π ≤ x ≤ π and
−π ≤ y ≤ π.
Problem 5
Give the steps to solve the following system of linear equations using MATLAB.
2x − 3y + 4z = 5
y + 4z + x = 10
−2z + 3x + 4y = 0
Problem 6
Write the commands for drawing the curve
x y
f (x, y) = −( )2 − ( )2 − 16
5 2
for −5 ≤ x ≤ 5 and −5 ≤ y ≤ 5. Using the surf function. Label the axis and given the
title. Remove the gird and color the curve in gray.
Problem 7
Write a function to create a vector of increasing values from mymin to mymax. The function
will receive two input arguments, mymin and mymax, and will return a vector with values
from mymin to mymax in steps of 1.
Problem 8
Compute the value of the following function: