Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB : while loops and for loops Can you please help code this problem in matlab language Problem #2 Background: An xls file containing the

MATLAB : while loops and for loops
Can you please help code this problem in matlab language image text in transcribed
Problem #2 Background: An xls file containing the energy consumption data of various energy sources for different years in the United States, measured in petaBTUs, has been provided. The first column of this file contains the years from when the data was taken, with the subsequent four columns containing the actual energy consumption data (with each column representing a different energy source). The first row of the file contains the names of the energy sources. Write a script that performs the following steps: (Data Entry) Create a variable for each column in the data file, and a row vector separating the names of the energy sources. In total, you should have five column vectors of the same size (for the years and four energy sources), and a 1x4 row vector of energy source names. Make sure these values are not hardcoded, but are instead extracted directly from the provided file. (Data Entry and Validation) Provide the user with a menu option listing all of the available energy sources to view. Make sure the energy source names are not hardcoded, and ensure no unintentional errors occur should the user exit the menu. 1. 2. Pormated ou) Create the table in dhecommand wrindow below using a for lop and fprint sacmentFollow window below using a for loop and fprintf statement. Follow 3. the sample output for formatting guidelines (including spacing and decimal places). Do not use the TABLE function. The formatting results will-be different (Control) Provide the user with a menu option to rerun the code. Should the user choose to do so, repeat Steps 2 & 3 until they decide to terminate the program. Ensure no unintentional errors occur should the user exit the menu. 4. Sample Outputs to Command Window (ignore Initial menu to select energy type: Select an energy type Fossil Fuels Elec. Net lmports Nuclear Renewable Example output table: Command Window Fossil Fuels Energy Consumption By Year [peta-BTU 2007 101.1 2006 99.86 2005 100.50 2003 93.21 100.35 x 22

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago