Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following table lists the protein, fat, carbohydrate, and energy content of

ID: 3668297 • Letter: T

Question

The following table lists the protein, fat, carbohydrate, and energy content of a number of common foods. Write a MATLAB program that computes the total grams of protein, fat and carbohydrates consumed daily based on the amount of each food type consumed during the day. The program should query the user to input the number of food items eaten during the day, the specific foods that were eaten, and the amount of each specific food eaten. Based on this information, the program should perform the following tasks:

Compute the total solids and water intake for the day (assume that the solids content is 30% and the water content is 70%).

Compute the total grams of protein, fat, and carbohydrates derived from each food.

Compute the available energy from protein, fat and carbohydrates eaten during the day (assume the available energy in food is as follows: carbohydrates – 4 calories/gram, fat – 9 calories/gram, and protein – 4 calories/gram).

Compare the available energy from protein, fat and carbohydrates obtained in c above to the average for Americans of 15% from protein, 40% from fat, and 45% from carbohydrates.

The MATLAB program should output the following:

Total solids and water intake for the day.

A labeled table listing the total grams of protein, fat, and carbohydrates derived from each food and the total grams of protein, fat, and carbohydrates consumed for the day.

A pie graph comparing the percentage fat, protein and carbohydrates in the daily diet.

A bar graph comparing the energy derived from protein, fat, and carbohydrates for the day to that for the average American diet.

Protein, Fat, Carbohydrate, and Energy Content of Food

Food

%Protein

%Fat

%Carbohydrate

Fuel value/100 g (kcal)

Apples

0.3

0.4

14.9

64

Asparagus

2.2

0.2

3.9

26

Bacon, broiled

25.0

55.0

1.0

599

Bread, white

9.0

3.6

49.8

268

Cheese

23.9

32.3

1.7

393

Milk, whole

3.5

3.9

4.9

69

Oatmeal

14.2

7.4

68.2

396

Orange

0.9

0.2

11.2

50

Pork, ham

15.2

31.0

1.0

340

Potatoes

2.0

0.1

19.1

85

Provide a flow chart that describes the Program and output for the following test data:

Breakfast:       200 g Oatmeal, 75 g milk, 1 orange (225 g)

Lunch:             1 apple (100 g), 4 slices bread (100 g), 90 g bacon, 40 g cheese

Dinner:                        350 g pork, 150 g asparagus, 150 g potatoes, 2 slices bread (50 g)

Protein, Fat, Carbohydrate, and Energy Content of Food

Food

%Protein

%Fat

%Carbohydrate

Fuel value/100 g (kcal)

Apples

0.3

0.4

14.9

64

Asparagus

2.2

0.2

3.9

26

Bacon, broiled

25.0

55.0

1.0

599

Bread, white

9.0

3.6

49.8

268

Cheese

23.9

32.3

1.7

393

Milk, whole

3.5

3.9

4.9

69

Oatmeal

14.2

7.4

68.2

396

Orange

0.9

0.2

11.2

50

Pork, ham

15.2

31.0

1.0

340

Potatoes

2.0

0.1

19.1

85

Explanation / Answer

load patients.mat;
T = table(LastName,Age,Height,Weight);
openvar('T')

normal way of creating a table

to get the details from database or enter data into it

Create and configure JDBC and ODBC data sources.

Establish multiple connections to databases.

Select tables and columns of interest.

Fine-tune selection using SQL query criteria.

Preview selected data.

Import selected data into MATLAB workspace.

Save generated SQL queries.

Generate MATLAB code

conn = database.ODBCConnection('dbtoolboxdemo','admin','admin')
sqlquery = 'select * from products';

result= exec(conn,sqlquery);
fetch(result,4)*pow(10,3)/fetch(result,1)+9*fetch(result,2)+4*fetch(result,3);

result.Data

close(result)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote