Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why isnt mine working? 1. [Submit on zyLabs] Please download GLaDOShaywire m This is a broken MATLAB file for a function that should be called

why isnt mine working? image text in transcribed
image text in transcribed
image text in transcribed
1. [Submit on zyLabs] Please download GLaDOShaywire m This is a broken MATLAB file for a function that should be called GLaDOS Please fix the filename. In addition to fixing that, you must fix a number of other things with this file. When properly functioning, GLaDOS is an AI that is capable of performing a series of experiments based on the inputs. The function GLaDOS should take four inputs, each an array of equal length containing the data for a series of tests, and return an output, the result of each test. The four inputs are arrays formatted in the following way. Each test has three different indicators of success: a button, a leaver, and a laser. Each test also has a difficulty level. The difficulty levels are all either 1, 2, or 3, and the indicators are all either 0 or 1. The result of each test should be an element in an array that is either successful (1) or not succesfful (0). The results of each test are determined by the following rules If difficulty is 1, one or more of the indicators needs to be true to pass the test. If the difficulty is 2, two or more of the indicators needs to be true to pass the test If the difficulty is 3, all of the indicators need to be true to pass the test. If the difficulty is not 1, 2, or 3, the test fails. However, none of this is clear from the haywire m file! You need to fix it by: Fixing all of the variable names! The program does not consistently use the same name for each variable. Choose new variable names that are more descriptive. Fix test results so they are assigned correctly Improve style by adding indents and white space and adding comments to describe what the program does (and to show that you know what it is doing). The purpose of this exercise is to practice debugging, and to practice good style. Please follow the procedures for debugging that we covered in lecture last week. You are also responsible for coming up with a method for determining whether your function is working correctly. Note that there is nothing wrong with how random number generating functions are called in this function: you will not have to fix calls to those functions. 1 function [result] - GLaDoS (bn, 1s,1v,d) 3 result zeros (numTest,1); 4 s for i1:numTest 6difficulty-rand(3); 7button rand (2)-1; 8 9 leaver-randi (2)-1; 10 switch difficulty 11 case 3 12 if button && leaver && laser 13 testResult 1; 14 else laser-randi(2)-1; s testResult e; 16 end 17 case 2 18 if button && leaver Il button && laser I leaver && laser 19 testResult 1; 20 else 21 testResult 0; 22 end 23 case 1 24 if button laser 25 testResult 1; 26 else 27 testResult 0; 28 end 29 otherwise 30 testResult e; 31 end leaver 31 end 32 result(i) testResult; 33 end Code to call your function 1x randi(20)+5; 2 for i 1:x 3 difficulty(i) -randi(3); 4 button(i) - randi (2)-1; laser(i) randi(2)-1; leaver(i)-randi(2)-1; 7 end 8 tests GLaDoS (button,laser, leaver,difficulty) Output Undefined function or variable 'numTest. Error in GLaDOS (line 3) result zeros (numTest,1)

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_2

Step: 3

blur-text-image_3

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

13. What are the benefits of BYOD to an organization?

Answered: 1 week ago