Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please answer this questions in mathlab showing all steps thanks Purpose: Writing functions in MatLab, data processing Degree of Difficulty: Tricky Just like

Can you please answer this questions in mathlab showing all steps thanks image text in transcribed
image text in transcribed
Purpose: Writing functions in MatLab, data processing Degree of Difficulty: Tricky 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, there's 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 Numbez Place pizzahut.cav in the same folder as your a9q3.a file. You can import pizzahut.cav with the fol- lowing code: pizzahut readtable (pizzahut.cav'.'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, usellcurly brackets instead of II 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) a 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, Nal.found " clean up data(data, NaN value) To declare a function in MatLab, youll need to create a new function file called 'clean,up.data.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! Purpose: Writing functions in MatLab, data processing Degree of Difficulty: Tricky 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, there's 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 Numbez Place pizzahut.cav in the same folder as your a9q3.a file. You can import pizzahut.cav with the fol- lowing code: pizzahut readtable (pizzahut.cav'.'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, usellcurly brackets instead of II 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) a 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, Nal.found " clean up data(data, NaN value) To declare a function in MatLab, youll need to create a new function file called 'clean,up.data.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