联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Matlab编程Matlab编程

日期:2018-04-19 10:24

Name: People you worked With: Lab Time: MTWRF 0000

Websites you used:

Submission Instructions

Turn all work in to Lab 0 and Lab 1 on Canvas, even if it is not complete yet. If you are not finished, complete the assignment outside of lab and re-submit to Lab 1 on Canvas. All labs are typically due before your next lab, but check the due date on Canvas.


BEFORE YOU BEGIN

1)Please read “ENGR112 Assignment Instructions.pdf” in the Canvas module “Start Here.”

2)Set up a file directory according to the instructions.


General note about labs

The labs are designed to introduce basic concepts to prepare you for the homework. When you get stuck, ask for help either from the TAs or from your neighbors.


Lab assignment instructions

Labs should be completed as follows:

?Read and complete zyBooks chapters and participation exercises before lab.

?Do zyBooks challenge exercises in the beginning of the assignment

oThese are graded for completion only

?Do additional open-ended problems with step-by-step instructions

oSubmit to Canvas when completed. They will be graded separately from the HW.

Learning objectives:

You should be able to answer the following questions

?What is a script file?

?What is the difference between a script file and the command window?

?How do you re-write a word problem as a script?

?How do you create variables?

?How can you examine the values of variables?

?How do you use the debugger?

New MATLAB commands

These are highlighted in bold in the instructions below.

?clear – clear the window

?clc – clear the command window

?clf – clear the figure

?fprintf() – formatted print

?ceil() – round up to the nearest integer?

zyBooks Challenge Exercises


Note: if you wait until the start of lab to read the zyBooks chapters YOU WILL NOT FINISH IN TIME. You may complete the optional challenges at any time for extra credit.

Do the challenge activities for the following in Week 1

1.MATLAB/Interpreter

a.Introduction to MATLAB challenge activities

2.Comments

a.Comments

3.Variables and assignments

a.Assigning a sum

b.Fahrenheit to Celsius

c.Multiple variables

4.Numeric expressions

a.Compute an expression

b.[Optional] Compute total cost

c.[Optional] Computing wind chill

5.Math functions

a.Population growth

b.[Optional] Coordinate geometry

c.[Optional] Tree height

6.Rounding functions

a.Luggage delivery

b.[Optional] Currency conversion


Additional Problems


Files to download to your Lab1 Folder

?Lab1GettingStarted.m

oYou will be working in this script for problem 1

oRename it to something like “Lab1Script1a.m”


Problem 0

First, familiarize yourself with the MATLAB environment. Open up the program. The main window will be some version of this (it might not automatically open all of the windows shown):


?Note: all of the window panes can be dragged out of the main window to be separate windows, then put back in again, rearranged and re-sized.

Problem 1

You are installing a wind farm on your friend’s farm in Oregon. The average cost of installing a wind turbine is around $50,000, and the turbine can produce 10kW per hour when the wind blows strong enough. Your friend’s farm uses (on average) about 1,500 kWh per month. The average cost per kWh in Oregon is 9.8 cents. Assume that the wind blows half the time.


Questions to answer:

1)How long will it take to pay off the turbine?

2)How many turbines would your friend need to meet all their energy needs?  


Deliverables:

a)Turn in a script which has the following in comments (no actual code)

i)What will the script do?

ii)What is the input to the problem?

iii)What is the output?

iv)What are the constants you need to solve the problem?

v)What is the equation you need to solve the problem?

vi)What is the process/algorithm you need to follow to create the output?

b)Turn in a second script which fills out the MATLAB commands for your first script in order to do the actual calculations

c)Copy the command window output and use it to

d)… answer the questions

e)(optional) Revise your script to ask the user for the amount of time there is enough wind to make the turbine go (same questions)


General Guidelines

You’re essentially going to follow how we solved the coffee problem in lecture. Open the Lab1GettingStarted.m script, rename the script something useful, then double click on it to open it up in the editor.

Step-by-Step Instructions:

1.a) In your script file, replace all sentences with [replace]in front of them according to their instructions. Make sure you answer the questions listed above in a).


The sentences you replace should include:

?Restate the problem/question

?Write down the basic approach to solving the problem(s)

?List the data/inputs for the problem

?Write the actual equation(s) you need to solve for each problem

?What is the output of your equation


Relevant zyBooks sections

?MATLAB/Interpreter, Comments, Scripts


Answer script here:

[60pts] 10 pts each for answering the 6 questions in 1a in your comments

% Copy and paste your script for part a) here by selecting all your code, copying, and pasting here. Make sure your formatting looks the same as MATLAB, with size 10 font.

1.b) Copy your script file and rename it something like “Lab1Script1b.m” so you can add the actual code in (use “Save as…” from the File menu).

?Create variables for all of your inputs and constants.

oAdd units as comments.

?Run the script and check the “Variable” window to make sure they show up correctly.

oClick “Change folder” when prompted.

?Write the equations to calculate the output(s)

oDon’t forget to write equations to convert to the correct units

?Run the script again; you should see your output variables in the variable window.

?Edit the fprintf statement to print out the outputs as full sentences.

?Copy the script to the answers document


Relevant zyBooks sections

?Variables and assignments

?Numeric expressions

?Math functions

?Basic output I

Answer script here:

[25 pts] 5 pts each, correctly set up input, output, constants, equation, and printed out the answer. Points taken off for not using comments to specify units (-10 pts), not using named variables for all constants, inputs, and output (-10 pts)

% Copy and paste your script for part b) here by selecting all your code, copying, and pasting here. Make sure your formatting looks the same as MATLAB, with size 10 font.

1.c) Copy the command window output down below.


Self-check: XX5X.7XX, 1 turbine


Relevant zyBooks sections

?Variables and assignments, Identifiers, Math functions

?Basic output 1

?Floating-point formatting


Command Window Output

[5 pts] for nice formatting of fprintf, using a sentence for the output

Copy and paste the command window output here (same font, size 10).

1.d) Answer the questions.


[10 pts] 5 pts each for answering the questions

How long will it take to pay off the turbine?

[Your answer here]


How many turbines would your friend need to meet all their energy needs?  

[Your answer here]

1.e) (optional) Alter your script so that you ask the user for the average time the turbine can operate instead of assigning it (see input).


Self-check:

Percentage time wind is blowing: 0.25

The number of days to pay-off is XXX3.XX1

The number of turbines needed is 1


Relevant zyBooks sections

?Basic input

Answer script here:

[+10 pts] Extra credit for altering your script to ask the user for the percentage the wind blows

% Copy and paste your script here with an example running the script at 25%. Make sure your formatting looks the same as MATLAB, with size 10 font.


Command Window Output

Copy and paste the command window output here (same font, size 10).


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp