It’s a great time to hit the road running. We have got enough Matlab lessons to start handing you some nice Matlab challenges to help you to assess yourself.
Here are some Matlab exercises.
Related Post: Free Matlab Alternative
1. Write a Matlab code corresponding to the above structogram.
2. What are the value of a, b and c at the end of this program?
Analyze the following code
1. Without using neither a calculator nor your computer, compute the values of x, y and z at the end of this program.
2. Now check your result using Matlab. (Simply copy the code, paste in Matlab and run it)
Let’s consider a cone. Write a Matlab program that computes the volume of a cone. Here is the formula you should be using.
Where r is the radius of the base and h is the height. Write a Matlab program that finds the radius of a cone. The program should first check that r and h are both positive. The precision of the result should be at most 3 decimal digit.
Let’s consider the following function saved in the file recursive.m
1. What will be the result of y=recursive(9,7)?
2. What will be the result of y=recursive(9,11)?
The following Matlab programs contain some elementary programming mistakes. Find the mistake and suggest a solution to each or them.
[php]r=input(‘Please enter a number: ‘);
fprintf(‘The number is zero’);
fprintf(‘The number is negative’);[/php]
Write a Matlab function that computes the following sum while requesting the value of x and n from the user.
To call the function, the user should use the following syntax
Consider the following Matlab program
[php]value=[2 5 7 -2 8 6 4 3];
Data=[4 5 3 7];
x=top(value, r, t);
y=top(value, s, r);
The function top defines the following way
[php]function[g]=top[ele, p, k]
Without using your computer, find the value of x, y and z at the end of this program.
We say a n × n matrix A is symmetric when for all i, j=1,…,n
Let’s consider the following matrices
A is symmetric but B is not
Write a Matlab function that will test if a matrix is symmetric or not. The function will return the number “1” if the matrix is symmetric and “0” if it is not.
To call the function you should use the following syntax
Solve the following equations using Matlab