Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In large programs, it can be helpful to have a function specifically for printing out an error message to the user or to a log

In large programs, it can be helpful to have a function specifically for printing out an error message to the user or to a log when an exception (an error) has occurred. Generally speaking, errors are tracked through unique error codes, making it easy for the programmer to implement. Assume you are given the task to implement a function for Mac users to print error messages based on some integer error code being passed into the function. Your manager wants you to implement a basic function for now to check the functionality. Implement a function called displayError , with no return value , that prints the integer error code passed to the function in the format specified. Below are two examples calling the function: displayError(-99)

'Exception thrown from error code -99.

>> displayError(-1)

'Exception thrown from error code -1.

>> Correct the bug in the function header!

% begin writing your function below function outArg = displayError(errorCode)

At their core, cell arrays are vectors of "cells" - universal containers that can hold numbers, strings, vectors, matrices... even other cells. Cell arrays use the "curly braces" {} to index individual cells, and parentheses () to index elements within each cell. To practice this, write a function cell_idx() that indexes a random cell array input for the following: 1. The third element of the second element in the array. For example: the number 4 in {'dog', [1 2 4 8 16], 14.567}; 2.The first element in the 4th element in the array. For example: the string 'cat' in {'foo', 'bar', [12 16; 32 -7], {'cat', 'rabbit', 'bat', 'dog'}} 3. The third cell in the array. For example: {'hey'} in {[2 1 -6 0], -81.23, 'hey', 'foobar'}

These three elements should be returned by your function in the same order. You can assume that the input mycell is always valid.

function [first, second, third] = cell_idx(mycell) first = ? second = ? third = ? end

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

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions