- Details
- Parent Category: Engineering Assignments' Solutions
We Helped With This Engineering Homework: Have A Similar One?

Category | Engineering |
---|---|
Subject | Other |
Difficulty | Undergraduate |
Status | Solved |
More Info | Engineering Homework Solutions |
Assignment Description
ENED 1090 HW #7
Due, Friday, November 10, 2017 at 5:00pm
Problem 1: Consider the code show below. Complete the table showing the values for the variables as the loop progresses. Do this without MATLAB first then check your results using MATLAB.
x = 2;
y = 1;
for k = 1:5
z = x - y;
x = y;
y = z;
end
| z | x | y |
Before Loop | Not Defined Before Loop | 2 | 1 |
k = 1 |
|
|
|
k = 2 |
|
|
|
k = 3 |
|
|
|
k = 4 |
|
|
|
k = 5 |
|
|
|
Problem 2: Consider the code show below. Complete the table showing the values for the variables as the loop progresses. Do this without MATLAB first then check your results using MATLAB.
t = [ 3 -7 -2 7 3 -8 ];
c = 0;
for k = 1:length(t)
if abs(t(k)) < 5
c = c + 1;
location(c) = k;
end
end
| c | location |
Before Loop | 0 | Not Defined Before Loop |
k = 1 |
|
|
k = 2 |
|
|
k = 3 |
|
|
k = 4 |
|
|
k = 5 |
|
|
k = 6 |
|
|
Problem 3: Numerical Algorithm for Determining Roots
The only mathematical operations the processor in a computing device (calculator, computer, cell phone, etc.) can perform are addition, subtraction, multiplication, and division. With this rather limited set of operations, how does your calculator (or Excel and MATLAB) determine values for more complicated mathematical operations such as:
To calculate values for these functions, an iterative algorithm or a numerical method that only requires the basic arithmetic operations of addition, subtraction, multiplication, and division is needed. In this problem, you will look at a very simple algorithm for computing the cube root of a number based on the Newton-Raphson algorithm.
The algorithm is
very simple. We want to find
- Make an initial guess for x: Est
- See how close you are: Error = abs(Est^3 – N)
- If the Error is too big, update the estimate as follows:
- Recalculate the Error using the new estimate
- Repeat this process to obtain a better guess
Write a MATLAB script that does the following:
- Prompts the user for the Number, N, for which he or she wishes to find the cube root
- Prompt the user for the number of iterations he or she wishes to perform
- Set the initial guess to 1
- Uses the algorithm describe above to repeatedly update the estimate and error for the number of times specified by the user
- Saves all the values for Est in a vector
- Outputs the following:
· The final value of the estimate for the cube root of N to 4 decimal places
· The final Error to 4 decimal places
· A plot with all the values for Est on the y axis and the iteration value on the x axis
Use your script to complete the table below. Paste your plot for the last row of the table where indicated.
N | Iterations | Final Estimate | Final Error |
3375 | 10 |
|
|
3375 | 12 |
|
|
3375 | 14 |
|
|
3375 | 16 |
|
|
PASTE PLOT HERE:
PASTE MATLAB CODE HERE:
Problem 4: Data Processing
As you’ve seen in labs 8 and 9, one of the benefits of using for loops is to easily process large amounts of data. For this problem, you will be looking at data for the value (in US $) of goods imported and exported for countries around the world in 2016. This information is found in the HW7_P4.xlsx file. Write a script in MATLAB that will do the following:
· Loads in the import data and export data from the Excel file
using the xlsread command (you should end up with 2 vectors, one for import
data and one for export data):
Example: data = xlsread('filename','range of
cells');
· Process all of the data to determine the following values:
o Number of countries with more exports than imports
o Number of countries with more imports than exports
o Number of countries that have the same number of imports and exports
o The maximum and minimum value of imports among the countries
o The maximum and minimum value of exports among the countries
· Display all requested values with appropriate units
PASTE SCRIPT OUTPUT HERE:
PASTE MATLAB CODE HERE:
Once you have completed the assignment, upload this Word document and any MATLAB m-files to Blackboard.