Write a MATLAB program to ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. If the user enters a 5 x 1 vector, use a warning statement to inform the user of their error, and set the new input value to be the transpose of the user input value. If the user enters a vector that is not the correct size or a 5 x 1 vector, ask the user to reenter the vector using the correct dimensions. The program should continuously check the user input each time it is entered. Continue to ask the user to input a new vector until the user has entered three tries. If the user fails to enter a vector correctly given three chances (including the first entry), use an error message to terminate the program. If the user enters a correct vector, or the vector is transposed, the program should restate the result for the user. Your ouput should match the following example's formatting exactly. The resulting 1 x 5 vector is: 1 2 3 4 5 Output formatting: The sentence is on the first line. The numbers are on the next line. The numbers are shown with no decimal places. The numbers are separated by a single space. Note: Because MATLAB Grader cannot accept user input, call the script "Generate_UserInput V" anywhere you would ask the user to input vector, like in line 14 of the provided template. The "Generate_UserInput V" script effectively replaces the following line of code: V=input('Enter a 1 x 5 vector: ');

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
MatLab problem. I am unsure of what the error message is referring to and why the code seems to be unable to work
Write a MATLAB program to ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. If the user enters a 5 x 1 vector, use a warning statement to
inform the user of their error, and set the new input value to be the transpose of the user input value. If the user enters a vector that is not the correct size or a 5 x 1 vector, ask
the user to reenter the vector using the correct dimensions. The program should continuously check the user input each time it is entered. Continue to ask the user to input a new
vector until the user has entered three tries. If the user fails to enter a vector correctly given three chances (including the first entry), use an error message to terminate the
program. If the user enters a correct vector, or the vector is transposed, the program should restate the result for the user. Your ouput should match the following example's
formatting exactly.
The resulting 1 x 5 vector is:
1 2 3 4 5
Output formatting:
Note: Because MATLAB Grader cannot accept user input, call the script "Generate_UserInput_V" anywhere you would ask the user to input a vector, like in line 14 of the provided
template. The "Generate_UserInput_V" script effectively replaces the following line of code:
V = input('Enter a 1 x 5 vector: ');
■ The sentence is on the first line.
▪ The numbers are on the next line.
Script
▪ The numbers are shown with no decimal places.
. The numbers are separated by a single space.
8% Outputs
9 % V - vector entered by user (corrected if entered transposed)
10
1%% Variables to be used
2% Inputs
3 % V vector entered by user
4 % Note: because MATLAB Grader cannot accept user input, call the script "Generate_UserInput_V" anywhere you would ask the user to inp
5% like in line 14. The "Generate_UserInput_V" script effectively replaces the following line of code:
6% V=input('Enter a 1 x 5 vector: ');
7
11 %% Program
12 % Start writing your program here
13
26
27
16 tries = 0;
17 correct = false;
18 while tries < 3 && correct == false
19
20
21
22
23
24
28
29
14 Generate_UserInput_V% In MATLAB Grader use this line in place of asking the user to enter a vector. This generates a variable V, as
15
30
31
32 end
33
v=input('Enter a 1x5 vector of numbers: ');
tries tries + 1;
[m, n] = size (v);
if m= 1 && n == 5
correct = true;
elseif m= 5 && n == 1
warning('You entered a 5x1 vector. Setting to transpose');
V = V';
correct = true;
else
end
disp('You entered an incorrect dimension vector');
34 if correct == false
35
error('You did not enter a 1x5 vector in 3 attempts! Terminating program. ');
36 else
37
38 end
disp (v);
Assessment: 0 of 6 Tests Passed (0%)
Warning and Error Check
Error using solution
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
Feedback hidden for errors below, as these errors may be due to the initial error. Show Feedback
Test Case 1
Save C Reset
Test Case 2
Test Case 3
MATLAB Documentation
▪ You must use the warning and error commands in your program to warn the user when they have entered an incorrect value and end the program if they do not
enter a correct value in the allotted three attempts.
Test Case 4
Formatted Output Check
▶ Run Script
?
Submit ?
0% (17%)
0% (17%)
0% (17%)
0% (17%)
0% (16%)
0% (16%)
Transcribed Image Text:Write a MATLAB program to ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. If the user enters a 5 x 1 vector, use a warning statement to inform the user of their error, and set the new input value to be the transpose of the user input value. If the user enters a vector that is not the correct size or a 5 x 1 vector, ask the user to reenter the vector using the correct dimensions. The program should continuously check the user input each time it is entered. Continue to ask the user to input a new vector until the user has entered three tries. If the user fails to enter a vector correctly given three chances (including the first entry), use an error message to terminate the program. If the user enters a correct vector, or the vector is transposed, the program should restate the result for the user. Your ouput should match the following example's formatting exactly. The resulting 1 x 5 vector is: 1 2 3 4 5 Output formatting: Note: Because MATLAB Grader cannot accept user input, call the script "Generate_UserInput_V" anywhere you would ask the user to input a vector, like in line 14 of the provided template. The "Generate_UserInput_V" script effectively replaces the following line of code: V = input('Enter a 1 x 5 vector: '); ■ The sentence is on the first line. ▪ The numbers are on the next line. Script ▪ The numbers are shown with no decimal places. . The numbers are separated by a single space. 8% Outputs 9 % V - vector entered by user (corrected if entered transposed) 10 1%% Variables to be used 2% Inputs 3 % V vector entered by user 4 % Note: because MATLAB Grader cannot accept user input, call the script "Generate_UserInput_V" anywhere you would ask the user to inp 5% like in line 14. The "Generate_UserInput_V" script effectively replaces the following line of code: 6% V=input('Enter a 1 x 5 vector: '); 7 11 %% Program 12 % Start writing your program here 13 26 27 16 tries = 0; 17 correct = false; 18 while tries < 3 && correct == false 19 20 21 22 23 24 28 29 14 Generate_UserInput_V% In MATLAB Grader use this line in place of asking the user to enter a vector. This generates a variable V, as 15 30 31 32 end 33 v=input('Enter a 1x5 vector of numbers: '); tries tries + 1; [m, n] = size (v); if m= 1 && n == 5 correct = true; elseif m= 5 && n == 1 warning('You entered a 5x1 vector. Setting to transpose'); V = V'; correct = true; else end disp('You entered an incorrect dimension vector'); 34 if correct == false 35 error('You did not enter a 1x5 vector in 3 attempts! Terminating program. '); 36 else 37 38 end disp (v); Assessment: 0 of 6 Tests Passed (0%) Warning and Error Check Error using solution Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering. Feedback hidden for errors below, as these errors may be due to the initial error. Show Feedback Test Case 1 Save C Reset Test Case 2 Test Case 3 MATLAB Documentation ▪ You must use the warning and error commands in your program to warn the user when they have entered an incorrect value and end the program if they do not enter a correct value in the allotted three attempts. Test Case 4 Formatted Output Check ▶ Run Script ? Submit ? 0% (17%) 0% (17%) 0% (17%) 0% (17%) 0% (16%) 0% (16%)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY