ENGR-125
Project
4: MATLAB Matrix and Conditional Statements
Due
Date:
Part A:
Create the following vector and matrix:
vectorA = [ 1 -4 13 20 -9];
matrixA= [1 -4 14 0 -17; 4 23 1 3 16; -4 -1 0 -1 8; 18 -7 -6 2 -8; -7 47 10 -5 3]; Please answer the following questions (in each case, please show MATLAB commands and answer): 1. Write the command to calculate the sum of the last three elements of vectorA;2. What is the command to calculate the sum of all elements of matrixA?3. Find the minimum value of each column of matrixA and their corresponding locations.4. Create a matrix, m1. The 1st row of matrixA is the 3rd row of m1, the 2nd row of matrixA is the 2nd row of m1 and the 3rd row of matrixA is the 1st row of m1.5. Assign 100 to the locations of matrixA where the current values are zero.6. Create a matrix by deleting the 3rd row of matrixA (do not create the matrix manually; use MATLAB commands/operations).7. Vertically concatenate two matrices. Create the first matrix by matrix generator ‘eye’ and the second matrix by matrix generator ‘ones’. Select the size of the matrices as 5 by 5. Show two ways to perform vertical concatenation.8. Create two submatrices of matrixA, m2, and m3. Both m2 and m3 should be matrices.9. What is the condition of matrix multiplication? Multiply m2 by m3.10. Multiply each element of m2 by the corresponding elements of m3.11. What is the difference between left and right division? Perform m2m3 and m2/m3.12. Solve the following set of linear equations (Using MATLAB):
Part B:
1. Draw
a flowchart and write a program to calculate the average of three numbers which
will be given as input.
2. Draw
a flowchart and write a program to find if a number is divisible by 5 or not.
3. Write
a program to find the greatest of three numbers using “if elseif … else end”
function.
4. Draw
a flowchart and write a program to print your grade based on a given percentage
using “if elseif … else end”.
Here is grading scale we use:
Grading Scale:
A’s: 100-90
B’s: 80+
C’s:70+
D’s: 60+
F: Below 60
5.
We wrote a program
to construct a Roulette game. The player could only bet on the following four
options. The payout is listed below. The player will start the game with
answering a yes. Then he can bet money on any of four following options. The
program is written in next page. We noticed two errors in our program if the
ball rolls on “0” or “00”, the roll for 37 or 38. The program will consider it
for high/low and even/odd (although in reality, you lost). Can you tell us how
to fix these errors?
Roulette Bet
Payout
Single Number
35 to 1
Dozen
2 to 1
Even/Odd
1 to 1
Low/High
1 to 1
clc
clear
disp(‘Welcome to ENGR-125 Casino’)
money=input(‘How much you want to
bet in dollars: ‘)
type=input(‘Tell me what type of
bet, for single enter 1, for dozen enter 2, for odd/even enter 3, for high/low,
enter 4: ‘)
if type==1
singl=input(‘please enter your bet
for a single number between 1 and 36’)
end
if type==2
dozen=input(‘please enter your bet
for the first dozen (1-12), enter 1, for 2nd dozen (13-24), enter 2, and for
3rd dozen (25-36),enter 3: ‘)
end
if type==3
oddeven=input(‘please enter your
bet for odd, enter 1, and for even enter 2: ‘)
end
if type==4
lowhigh=input(‘please enter your
bet for low, enter 1, and for high enter 2: ‘)
end
roll=randi([1 38]) % 1-36 for numbers, 37 for “0” and 38 for
“00”
fprintf(‘The roll is at %dn’,
roll)
rolldozen=ceil(roll/12)
fprintf(‘The roll dozen is at
%dn’, rolldozen)
if rem(roll, 2)==1
rolloddeven=1
else
rolloddeven=2
end
if roll<19
rolllowhigh=1
else
rolllowhigh=2
end
% clacualte the payout
% payout for type one
if type==1&&(singl==roll)
payout=35*money
money=money+payout
elseif type==1
money=0
disp('You Lost and Try again')
end
if
type==2&&(dozen==rolldozen)
payout=2*money
money=money+payout
elseif type==2
money=0
disp('You Lost and Try again')
end
if
type==3&&(oddeven==rolloddeven)
payout=money
money=money+payout
elseif type==3
money=0
disp('You Lost and Try again')
end
if
type==4&&(lowhigh==rolllowhigh)
payout=money
money=money+payout
elseif type==4
money=0
disp('You Lost and Try again')
end
ENGR-125 Project 4: MATLAB Matrix and Conditional Statements Due Date: Part A:
Struggling With a Similar Paper? Get Reliable Help Now.
Delivered on time. Plagiarism-free. Good Grades.
What is this?
It’s a homework service designed by a team of 23 writers based in Carlsbad, CA with one specific goal – to help students just like you complete their assignments on time and get good grades!
Why do you do it?
Because getting a degree is hard these days! With many students being forced to juggle between demanding careers, family life and a rigorous academic schedule. Having a helping hand from time to time goes a long way in making sure you get to the finish line with your sanity intact!
How does it work?
You have an assignment you need help with. Instead of struggling on this alone, you give us your assignment instructions, we select a team of 2 writers to work on your paper, after it’s done we send it to you via email.
What kind of writer will work on my paper?
Our support team will assign your paper to a team of 2 writers with a background in your degree – For example, if you have a nursing paper we will select a team with a nursing background. The main writer will handle the research and writing part while the second writer will proof the paper for grammar, formatting & referencing mistakes if any.
Our team is comprised of native English speakers working exclusively from the United States.
Will the paper be original?
Yes! It will be just as if you wrote the paper yourself! Completely original, written from your scratch following your specific instructions.
Is it free?
No, it’s a paid service. You pay for someone to work on your assignment for you.
Is it legit? Can I trust you?
Completely legit, backed by an iron-clad money back guarantee. We’ve been doing this since 2007 – helping students like you get through college.
Will you deliver it on time?
Absolutely! We understand you have a really tight deadline and you need this delivered a few hours before your deadline so you can look at it before turning it in.
Can you get me a good grade? It’s my final project and I need a good grade.
Yes! We only pick projects where we are sure we’ll deliver good grades.
What do you need to get started on my paper?
* The full assignment instructions as they appear on your school account.
* If a Grading Rubric is present, make sure to attach it.
* Include any special announcements or emails you might have gotten from your Professor pertaining to this assignment.
* Any templates or additional files required to complete the assignment.
How do I place an order?
You can do so through our custom order page here or you can talk to our live chat team and they’ll guide you on how to do this.
How will I receive my paper?
We will send it to your email. Please make sure to provide us with your best email – we’ll be using this to communicate to you throughout the whole process.
Getting Your Paper Today is as Simple as ABC
No more missed deadlines! No more late points deductions!
You give us your assignments instructions via email or through our order page.
Our support team selects a qualified writing team of 2 writers for you.
In under 5 minutes after you place your order, research & writing begins.
Complete paper is delivered to your email before your deadline is up.
Want A Good Grade?
Get a professional writer who has worked on a similar assignment to do this paper for you