上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment11

Homework one for MATLIB(Due:11:00 pm March.1) 1.Temperature conversion Write a script that outputs a table of degrees Fahrenheit and degrees Centigrade starting with-40 degrees Fahrenheit,ending with 140 degrees Fahrenheit in increments of 10 degree Fahrenheit.The conversion from degrees Fahrenheit to degrees Centigrade is: C=(F-32)*5/9 You should do it in MATLAB way. Function Declaration: Function C=f2c (F) Sample output: Tempreture Convertion Table Fahrenheit Centigrade -40 -40.0 -30 -34.4 -20 -28.9 -10 -23.3 0 -17.8 130 54.4 140 60.0 Although only the data matters,you still should try your best to follow the format Notes for submission: You should save your homework in an m file and submit your homework to the Sakai using attachment. Name you file in the following matter.The format is important,if you did not follow this rule, your homework may not be able to be grated correctly or on time. sYourlD_hwk1_1.m Example s5073709022hwk1_1.m
Homework one for MATLIB (Due: 11:00 pm March. 1) 1. Temperature conversion Write a script that outputs a table of degrees Fahrenheit and degrees Centigrade starting with -40 degrees Fahrenheit, ending with 140 degrees Fahrenheit in increments of 10 degree Fahrenheit. The conversion from degrees Fahrenheit to degrees Centigrade is: C = (F − 32) * 5 / 9 You should do it in MATLAB way. Function Declaration: Function C = f2c (F) Sample output: Although only the data matters, you still should try your best to follow the format Notes for submission: You should save your homework in an m file and submit your homework to the Sakai using attachment. Name you file in the following matter. The format is important, if you did not follow this rule, your homework may not be able to be grated correctly or on time. sYourID_hwk1_1.m Example : s5073709022_ hwk1_1.m

2.Turn pseudo-code into real code Write a MATLAB code to find the zero of a function.Your code will be made up of three M-files: a script M-file to drive the process a function M-file that finds zeros using a Newton procedure (explained below) a function M-file that contains the function for which you are finding the zero. Pseudo-code for the three pieces is given below.Construct the MATLAB code. Script M-file (a)Prompt the user for an initial guess for the x value at which the zero occurs. (b)Call the zero-finding function,with the initial guess as the input argument,and the final answer and number of steps it took to find the final answer as the output arguments. (c)Print out the final answer and the number of steps it took to find the final answer in some self-explanatory format. Function M-file for finding a Zero (a)This function has one input argument,the initial guess for x. (b)This function has two output arguments,the final approximation of the xvalue at which the zero is found,and the number of steps it took to find it. (c)Set a convergence criterion of s=10-6. (d)Initialize the number of iterations to zero. (e)Carry out the following steps until the absolute value of f(x)<&where f is the function you are zeroing,and x is your current approximation of the zero. Calculate an approximation to the derivative of the function at this point,from f(c)=f(r+e)-f(c-) 2e Calculate a new approximation to the zero,from x=x-f(x)/f(x) Update the number of steps that you have taken through the loop. (⑤Return to main Hint:Function Prototype function [x n]findZero (initGuess) Function M-file f (a)This function has one input argument,x. (b)This function has one output argument,y. (c)The relation is y=x2-sin()/x; Hint:Function Prototype function y=yValue (x)
2. Turn pseudo-code into real code Write a MATLAB code to find the zero of a function. Your code will be made up of three M-files: • a script M-file to drive the process • a function M-file that finds zeros using a Newton procedure (explained below) • a function M-file that contains the function for which you are finding the zero. Pseudo-code for the three pieces is given below. Construct the MATLAB code. Script M-file (a) Prompt the user for an initial guess for the x value at which the zero occurs. (b) Call the zero-finding function, with the initial guess as the input argument, and the final answer and number of steps it took to find the final answer as the output arguments. (c) Print out the final answer and the number of steps it took to find the final answer in some self-explanatory format. Function M-file for finding a Zero (a) This function has one input argument, the initial guess for x. (b) This function has two output arguments, the final approximation of the xvalue at which the zero is found, and the number of steps it took to find it. (c) Set a convergence criterion of ε = 10−6 . (d) Initialize the number of iterations to zero. (e) Carry out the following steps until the absolute value of f(x) < ε where f is the function you are zeroing, and x is your current approximation of the zero. • Calculate an approximation to the derivative of the function at this point, from • Calculate a new approximation to the zero, from • Update the number of steps that you have taken through the loop. (f) Return to main Hint: Function Prototype function [x n] = findZero (initGuess) Function M-file f (a) This function has one input argument, x. (b) This function has one output argument, y. (c) The relation is Hint: Function Prototype function y = yValue (x)

Notes for submission: For this problem,You need only to submit your zero-finding function to the Sakai using attachment. Name you zero-finding function in the following matter.The format is important,if you did not follow this rule,your homework may not be able to be grated correctly or on time. sYourlD_hwk1_2.m Example s5073709022_hwk12.m
Notes for submission: For this problem, You need only to submit your zero-finding function to the Sakai using attachment. Name you zero-finding function in the following matter. The format is important, if you did not follow this rule, your homework may not be able to be grated correctly or on time. sYourID_hwk1_2.m Example : s5073709022_ hwk1_2.m
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment 14.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment 10_1.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment 10.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_VIII.结构体与共用体.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_VII.指针.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_VI.编译预处理.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_V.数组.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_IX.文件.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_IV.函数和程序结构.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_III.流程控制.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_II.基本数据类型和运算.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C语言_I.C语言概述.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_VII.类与对象的高级操作.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_VI.类与对象.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_V. 流库.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_IV.异常处理与模板.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_III.多态性.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_II.继承与派生.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_I.运算符重载.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Solution for Practice Final 2.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment12.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Assignments_assignment13.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Other Resources_intrduction to computer and programming with C++ and MATLAB.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation 11.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_recitation 14.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Sample Exam Questions_midterm 2 sample solution.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Sample Exam Questions_Midterm 2008 sample.pdf
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第1-2章 计算机简介、C++编程入门.ppt
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第4-5章 控制结构.ppt
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第6章 过程封装——函数.ppt
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第7章 数组.ppt
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第8章 间接访问——指针.ppt
- 上海交通大学:《程序设计基础》课程教学资源(PPT课件讲稿)第9章 数据封装——结构体.ppt
- 上海交通大学:《计算机硬件技术》课程PPT教学课件(计算机概论,孙德文).ppt
- 上海交通大学:《理论力学》课程教学资源(PPT讲稿)平面矢量.ppt
- 中华人民共和国国家标准(GB/T8567一2006 代替GB/T8567-1988)计算机软件文档编制规范 Specification for computer software documentation.pdf
- 《软件工程概论》课程教学资源(参考资料)Guide to the Software Engineering Body of Knowledge(SWEBOK)Version 3.0.pdf
- 《软件工程概论》课程教学资源(参考资料)软件工程知识体系指南(2004版).pdf
- 上海交通大学:《软件测试与质量控制》课程教学资源(课件讲稿)第1章 Introduction of software testing.pdf
- 上海交通大学:《软件测试与质量控制》课程教学资源(课件讲稿)第3章 Test environment and tools.pdf