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

Example 1 function tokenList split(str,delimiter) tokenList ={} remain str; ii=1: while ~isempty(remain), [token,remain]strtok(remain,delimiter); tokenList(ii}token; ii =ii+1; end Example 2 function y upStairs(n) if n ==1 y=1: elseif n ==2 Y=2; elseif n ==3 Y=4; else y upstairs(n-1)+upstairs(n-2)+upstairs(n-3); end Example 3 Write a function,out combine(obj,n),which outputs all possible combinations of n characters from the characters in "obj"."obj"is a string and "n"is an integer.NO characters in "obj"are repeated. Please use recursion method. Sample Out combine (abcd',2) Out ab ac ad be bd cd Think about it yourselves.I will show you in the next recitation class. What if obj has repeated characters?Also think about arrangements of n characters instead of combinations with and without characters repeated
Example 1 function tokenList = split(str, delimiter) tokenList = {}; remain = str; ii = 1; while ~isempty(remain), [token, remain] = strtok(remain, delimiter); tokenList{ii} = token; ii = ii+1; end Example 2 function y = upStairs(n) if n == 1 y = 1; elseif n == 2 y = 2; elseif n == 3 y = 4; else y = upStairs(n-1) + upStairs(n-2) + upStairs(n-3); end Example 3 Write a function, out = combine(obj, n), which outputs all possible combinations of n characters from the characters in “obj”. “obj” is a string and “n” is an integer. NO characters in “obj” are repeated. Please use recursion method. Sample Out = combine(‘abcd’,2) Out = ab ac ad bc bd cd Think about it yourselves. I will show you in the next recitation class. What if obj has repeated characters? Also think about arrangements of n characters instead of combinations with and without characters repeated

Example 4 function heatConduction() tBar=[zeros(1,99),100]; time 1; old avg sum(tBar)/100; while true time time +1; tBar(time,1)=0; tBar(time,100)=100; tBar(time,2:99)=0.5 (tBar(time-1,1:98)+tBar(time-1,3:100)); new avg sum(tBar (time,:))/100; if abs(new avg -old avg)<0.005 break; end old avg new_avg; end tBar(end+1,end+1)=0; pcolor(1:101,1:time+1,tBar) colormap gray shading flat colorbar xlabel('Length'); ylabel('Time'); Color maps. hsv -Hue-saturation-value color map. hot Black-red-yellow-white color map. gray Linear gray-scale color map. bone -Gray-scale with tinge of blue color map. copper Linear copper-tone color map. pink Pastel shades of pink color map. white -All white color map. flag -Alternating red,white,blue,and black color map. lines Color map with the line colors. colorcube -Enhanced color-cube color map vga -Windows colormap for 16 colors. jet Variant of HSV. prism -Prism color map. cool -Shades of cyan and magenta color map. autumn Shades of red and yellow color map. spring -Shades of magenta and yellow color map. winter -Shades of blue and green color map. summer Shades of green and yellow color map
Example 4 function heatConduction() tBar = [zeros(1,99),100]; time = 1; old_avg = sum(tBar)/100; while true time = time + 1; tBar(time,1) = 0; tBar(time,100) = 100; tBar(time,2:99) = 0.5 * (tBar(time-1,1:98) + tBar(time-1,3:100)); new_avg = sum(tBar(time,:))/100; if abs(new_avg - old_avg) < 0.005 break; end old_avg = new_avg; end tBar(end+1,end+1) = 0; pcolor(1:101,1:time+1,tBar) colormap gray shading flat colorbar xlabel('Length'); ylabel('Time'); Color maps. hsv - Hue-saturation-value color map. hot - Black-red-yellow-white color map. gray - Linear gray-scale color map. bone - Gray-scale with tinge of blue color map. copper - Linear copper-tone color map. pink - Pastel shades of pink color map. white - All white color map. flag - Alternating red, white, blue, and black color map. lines - Color map with the line colors. colorcube - Enhanced color-cube color map. vga - Windows colormap for 16 colors. jet - Variant of HSV. prism - Prism color map. cool - Shades of cyan and magenta color map. autumn - Shades of red and yellow color map. spring - Shades of magenta and yellow color map. winter - Shades of blue and green color map. summer - Shades of green and yellow color map
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation 1.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_vector_string.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Start with C plusplus.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Random Number_Graphics.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_programming style guide for C plusplus.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_objects and classes.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Introduction to Vg101.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Introduction to Computer and Programming.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Function.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_files_DataBase Design.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Expressions and Statements.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_examples on class design.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_Array and its Applications.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_20 Looking Ahead.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_19 Recursion 1.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_16 MATLAB environment short.pdf
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Lecture Notes_15 Introduction to matlab.pdf
- 上海交通大学:《数据库系统原理 The principle of Database System》教学资源_Chapter 1 Introduction.pdf
- 上海交通大学:《数据库系统原理 The principle of Database System》教学资源_第二章习题与答案(第三版).doc
- 上海交通大学:《数据库系统原理 The principle of Database System》教学资源_第三章习题与答案(第三版).doc
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation IX.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation V.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation VII.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation VIII.ppt
- 上海交通大学:《程序设计基础》课程教学讲义(密西根学院)Recitation Notes_Recitation X.ppt
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第十四章 MCS-51单片机(1/2).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第十四章 MCS-51单片机(2/2).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第一章 微机原理与接口技术绪论(朱兰娟).pdf
- 上海交通大学:《微机原理与接口技术》课程教学资源(课件讲稿)第二章 8086系统结构.pdf
- 上海交通大学:《数据库系统原理 The principle of Database System》课程教学资源(课件讲稿)chapter9 SQL in a server environment.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Pointer Review Solution.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Pointer Review.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Practice Final 1.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_practice Final 2.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_practice Final 3.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Solution for Practice Final 1.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)05年期末习题_Solution for Practice Final 2.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_I.运算符重载.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_II.继承与派生.pdf
- 上海交通大学:《程序设计基础》课程教学资源(习题集)C++语言_III.多态性.pdf