Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Just like in Python, you can define functions in MatLab. One property of MatLab functions is that they can return more than 1 value! Like

image text in transcribedimage text in transcribed

Just like in Python, you can define functions in MatLab. One property of MatLab functions is that they can return more than 1 value! Like in the last question, theres a file called pizzahut.csv. It contains 1 row per Pizza Hut location. The file has the following columns: Latitude, Longitude,Location,Address and Phone Number Place pizzahut.csv in the same folder as your a9q3.m file. You can import pizzahut.csv with the fol- lowing code: pizzahut - readtable('pizzahut.csv', 'ReadVariableNames',false); You now have a ta ble called pizzahut. Tables are a bit different in MatLab. They can have different types of values in their columns, instead of an ordinary matrix whose values must all be of the same time. To access the value inside an entry of our table, use { } curly brackets instead of ? brackets. Ex: pizzahut( 1 , 1 } gives -149.9147. Our table contains different data types in each column. You may need to check the data type of the cell to determine how to check for NaN. Ex: isnumeric(current value) & isnan (current value) would check whatever current value is for NaN if it's a number column. Sometimes the data you receive is incomplete, or has invalid entries. Some invalid entries are denoted as NaN. Which means 'Not a Number. Write the following function: function altered-data, NaN-found = clean_up_data(data, NaN_value) To declare a function in MatLab, you'll need to create a new function file called 'clean_up_data.m'. You will then place your function declaration: function altered_data, NaN_found - clean_up_data (data NaN_value) inside this new .m file. You will be able to call this function from your a9q3.m like you would any function in Python This clean_up_data function needs to . Count the number of 'NaN' entries the data has, and return it as the variable NaN found. . Remove each row that contains a 'NaN' value Return the altered data as the variable new_data. Your file will need to read in pizzahut.csv, then pass that data to your clean_up_data function. After you've passed the variable pizzahut to your clean_up_data function, print out the returned number of NaN's that were found. Your output should look something like: Number of NaNs found: 10 Hint: There are many ways to remove NaN values. Use your googlefu, and do some research

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago