0% found this document useful (0 votes)
39 views2 pages

Ejercicios Matlab 1

This document introduces 8 practice problems for learning MATLAB. Problem 1 has the student create a 5x5 matrix with given values. Problem 2 defines a function and has the student compute the value of Y for given inputs. Problem 3 provides commands to plot 2 functions on the same figure with different styles. Problem 4 defines a function Z(x,y) and has the student calculate and plot its values. Problem 5 gives a system of linear equations for the student to solve. Problem 6 provides a function for the student to plot as a 3D surface. Problem 7 defines a function to create a vector between two values. Problem 8 defines a recursive function for the student to compute values of from 1 to 20.

Uploaded by

Missmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Ejercicios Matlab 1

This document introduces 8 practice problems for learning MATLAB. Problem 1 has the student create a 5x5 matrix with given values. Problem 2 defines a function and has the student compute the value of Y for given inputs. Problem 3 provides commands to plot 2 functions on the same figure with different styles. Problem 4 defines a function Z(x,y) and has the student calculate and plot its values. Problem 5 gives a system of linear equations for the student to solve. Problem 6 provides a function for the student to plot as a 3D surface. Problem 7 defines a function to create a vector between two values. Problem 8 defines a recursive function for the student to compute values of from 1 to 20.

Uploaded by

Missmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Introduction to Matlab

UCM-CompuMate Practice 1 March 14, 2019

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.

Y = |XeaX − cos(bX)|, a = 11, b = π, X = {2, 4, 6, 8}

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:

Z(x, y) = ex cosy + sin(x2 − y)

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:

y(n) = 13 (13 + 23 )(13 + 23 + 33 )...(13 + 23 + ... + n3 )

for n = 1 to 20. Try to complete it in different way.

You might also like