Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab code Function Name: veggieParty Inputs: ( cell ) Cell array of various dishes and their ratings ( char ) Rating type of interest (

Matlab code

Function Name: veggieParty

Inputs:

( cell ) Cell array of various dishes and their ratings

( char ) Rating type of interest

( char ) Filename of an ingredients text file, including file extension

Outputs:

(cell ) Sorted cell array of dishes and ratings

( cell ) 1xN cell array of the ingredients needed to make the top rated dish

Banned:

 sortrows(), strsplit() 

Background:

You're planning a party where people are vegetarians. It's a veggie party!

Function Description:

Write a function called veggieParty that takes in a cell array of vegetarian dishes with their rating scores and sorts the cell array based on a specific rating type. The function should also determine the ingredients needed to make the top rated dish.

The provided cell array input will contain all the possible dish options in the first column, and various types of rating scores for each dish in the other columns. The first row of the cell array will contain the headers for each column. Determine which column contains the rating of interest, as specified by the second input, and sort the entire cell array based on the values from this column in descending order, such that the top rated dishes according to the rating type are at the top of the array.

Then, determine the ingredients of the top rated dish using the text file given as the third input. Each line in the text file will be formatted in the following way:

 : ,,... 

Output the sorted cell array of dishes with ratings and the 1xN cell array of the ingredients needed to make the top rated dish. The ingredient array should be in the same order as in the text file.

Notes:

The first column of the input cell array will always contain the dish names.

The rating type columns can be in any order.

There can be any number of ingredients for any particular dish.

The rating type of interest is guaranteed to appear as a header in the input cell array.

The top rated dish is guaranteed to be found in the ingredients text file.

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