Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only answer using Matlab code. Using Python, C++ or any other language will result in reporting. Do not repost a previous answer or I will

image text in transcribedimage text in transcribedimage text in transcribedOnly answer using Matlab code. Using Python, C++ or any other language will result in reporting. Do not repost a previous answer or I will also report you. This is all part of one large problem. Thank you.

Correct all errors in the provided script. Remember that some errors are fatal (result in an error message) while others simply cause the program to produce incorrect results. You can assume that you have fixed all errors when the checker passes all tests. There is one bug in the program that causes an infinite loop. If you submit in Grader without fixing that bug, the server will time out. We recommend copying the code to MATLAB on the desktop and only submitting in Grader once the syntax and fatal runtime errors have been fixed. Some background information that might be useful The quadratic formula. Given ax? +bx+c = 0, the roots are 71 -+-dac - and ---- If the descriminant (the expression under the square root sign) is positive, there are two real roots. If the discriminant is 0there is a double root and if the discriminant is negative, there are no real roots. The Fibonacci sequence. This is a sequence of integers defined as follows: F.=F1+F2.23 In other words, the next number in the sequence is the sum of the previous two numbers. Some sources use [O. 11 for the first two numbers, and some use 11. 11. This problem uses [0, 1], so the sequence is F = {0.1.1,2 3,5. 8. 13. 21. 34. Script Reset MATLAB Documentation 2. It is recommended that you debug this program offline and submit only once you have corrected the errors ***** These 3 loops all calculate the sun of the integers from 1 through 1800 & for number = 1:1eee 9 total = total + number; 10 end 11 fprintf('The sum of the numbers from 1 through 1090 is miin, total): 12 EE 13: 14 the Total = @: is while k 1898 24 the Total 2 - the Total_2 . ki 25 k = -1; 26 end 27 28 fprintf('The sun of the numbers From 1 through 1808 is isn', the total); 29 26 30 %These two structures do the same thing - find the roots of a quadratic, 31 and print out the real roots, if any 32 33 a 1: 34 b = 3; as = 2: 36 27 discriminant = b^2 - 4ac; 37 discriminant = b^2 - 4ac; 39 Refer to the quadratic formula given in the problen description 48 41 it discriminant > @ 42 root1 = (-b-sqrt(discriminant) y/2a; 43 root2 = (-b-sqrt(discriminant))/2*a; 44 fprint('The roots are sf and % ", root1, root2): 46 elseif discriminant == 0 47 root1 = -b/(2*a); 48 root2 = NaN: 49 #printf('The root is XF and fin', root1); se else SI fprintf("There are no real roots "); 52 end 53 54 aa = 1 55 bb = -8; 56 CC = 16; 57 58 discriminant = b^2 - 4aacc; 59 be switch discriminant case discriminant> 62 root3 = (-bb+sqrt(bb^2 - 4*22*cc)/(2*2); 63 root4 = (-bb-sqrt(bb^2 - 4*22*cc)/(2*aa); 64 fprintf("The roots are X and XF ', roots, route); 65 case discriminant as e 67 root3 = -b/(2aa); 68 root 4 = Nan; fprintf('The root is xf ', root3); 20 otherwise 71 #printf('There are no real rootsin'); 72 end 73 74 % 75 %This progran calculates and plots the Fibonacci numbers that are less than 100 76 % When the loop completes, only those numbers LESS than 180 should be stored in the array Fibonacci Number 78 79 fibonacci Number=[0, 1]; se 81 %first time through the loop, calculating the 3rd Fibonacci number 32 Index = 3 83 while fibonacciNumber =100) 1:11; 96 97 The following lines will only be executed if the previous line does not create an error 99 100 191 182 fprintf('There are 1 Fibonacci numbers that are less than 100;5, length(Fibonacci Number)); fprintf("They are: W') fprintf(" ', fibonacci Number); lee fprintf("There are %i Fibonacci numbers that are less than 100; length(fibonacciNumber)); 181 fprintf("They are: In 102 fprintf("XX, FibonacciNumber): 123 plot(1: index, fibonacci Number) 184 105 catch ME 186 102 Switch ME. identifier 188 case MATLAB: assertion: failed 109 disp('Incorrect set of Fibontact numbers.) 11e case 'MATLAB: Samelen 111 disp'error in plot - vectors not the same length 112 otherwise 11: disp('Something is wrong with the Fibonacci number code) 114 end 115 116 end 117 118 % 119 This program calls the user-defined function, GPAC) to calculate a 120 student's grade point average 122 122 Grades = ABACAADODAC 122 Credits - [43454453324]; 124 Name = "Joe": 125 GPAValue = gradePointAverage (grades, credits): 126 fprintf(''GPA is din', GPAValue); 127 128 129 130 function I gradepointAverage) - GPA[letterGrades, nunCredits > 13 XUNTITLED Sunnary of this function goes here 132 % Detailed explanation goes here 133 134 qualitypoints = (letterGrades == 'A')*4 + (letterGrades=='')*3 + (letterGrades == 'C)*2 + (letterGrades=='D')*1; 135 136 totalPoints = sum(qualityPoints. *credits): 137 138 gradePoint Average = totalPoints/sum(credits): 139 end 149 141 142 143 Run Script 2 Assessment: Submit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of sales forecasting.

Answered: 1 week ago