下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上 1.编制一个脚本,查找给定字符串中指定字符出现的次数和位置;str='hopes,dreams,hold up,hold up'>> findstr(str,'o') %位置ans = 2 15 23>> a=findstr(str,'o');n=length(a) %次数n = 32编写一个脚本,判断输入字符串中每个单词的首字母是否为大写,若不是则将其修改为大写,其他字母为小写。>> str='i have a dream come true'nlength=len
2、gth(str);for k=1:nlength if (k=1 | isspace(str(k-1)&&(str(k)<='z'&&str(k)>='a')str(k)=char(double(str(k)-32); endenddisp(str);I Have A Dream Come True3创建2×2 单元数组,第1、2 个元素为字符串,第三个元素为整型变量,第四个元素为双精度(double)类型,并将其用图形表示。>> A=cell(2,2) A(1,1)='beijing
3、39; A(2,1)='BEIJING'A(1,2)=uint8(5);A(2,2)=1,2;4,7 cellplot(A)A = A = 'beijing' 5'BEIJING' 2x2 double4创建一个结构体,用于统计学生的情况,包括学生的姓名、学号、各科成绩等。然后使用该结构体对一个班级的学生成绩进行管理,如计算总分、平均分、排列名次等。>> student=struct('name','bam','mark','jimin','number'
4、,1,2,3,'scores',75,89,82,93,78,90,85,62,77 ,'subject','english,math,chinese','english,math,chinese','english,math,chinese')student = 1x3 struct array with fields: name number scores subject>> student(1)ans = name: 'bam' number: 1 scores: 75 89 82
5、 subject: 'english,math,chinese'>> student(2)ans = name: 'mark' number: 2 scores: 93 78 90 subject: 'english,math,chinese'>> student(3)ans = name: 'jimin' number: 3 scores: 85 62 77 subject: 'english,math,chinese'>> >> sum(student(1).sc
6、ores)ans = 246>> sum(student(2).scores)ans = 261>> sum(student(3).scores)ans = 224 mean(student(1).scores)ans = 82>> mean(student(2).scores)ans = 87>> mean(student(3).scores)ans = 74.6667>> new,index=sort(student.scores,'descend') new = 93 90 89 85 82 78 77 75 6
7、2index = 4 6 2 7 3 5 9 1 8>> student(1).mean= mean(student(1).scores)student(2).mean=mean(student(2).scores)student(3).mean= mean(student(3).scores)student = 1x3 struct array with fields: name number scores subject meanstudent = 1x3 struct array with fields: name number scores subject meanstud
8、ent = 1x3 struct array with fields: name number scores subject mean>> student(1)ans = name: 'bam' number: 1 scores: 75 89 82 subject: 'english,math,chinese' mean: 82>> student(2)ans = name: 'mark' number: 2 scores: 93 78 90 subject: 'english,math,chinese' mean: 87>> student(3)ans = name: 'jimin' number: 3 scores: 85 62 77 subject: 'english,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年湖南省吉首市高一化学上册期末考试自测卷含答案(巩固)
- 2026年福建省福安市高三历史上册期末考试试卷【考点梳理】附答案
- 2026年山西省河津市高三生物上册期末考试模拟卷带答案
- 2026年广东省化州市高三物理下册期末考试模拟试卷及答案
- 五年级数学下册 第6课时 列方程解决实际问题
- 2026网格员招聘笔试练习题库(含答案)
- 民航安全检查课标教案
- 基于机器视觉的毛杆缺陷检测技术:原理、应用与优化
- 基于机器学习的图书自动分类系统:设计、实现与优化
- 基于本体的改模知识语义建模与推理方法的深度探索
- 2026秋小学人教版(新教材)数学六年级上册第三单元学情测试练习卷及答案
- 雨课堂学堂在线学堂云《创伤重症医学(陆军军医大学)》单元测试考核答案
- DTII(A)带式输送机计算书Ver1.57蓝天(95版,20140109)
- 2026年中国创新方法大赛理论模拟题
- 26秋新人教PEP版六上英语知识点总结
- CSCO乳腺癌诊疗指南(2026版)
- 2026年陕西省、山西省、青海省、宁夏高考历史试卷(含答案及解析)
- 全过程造价控制咨询服务方案投标文件(技术方案)
- 半导体厂务工程师笔试真题及答案
- GB/T 47298-2026土壤碳酸盐含量的测定气量法
- 【阳江】2025年广东阳江市江城区退役军人服务机构面向随军家属招聘工作人员4人笔试历年典型考题及考点剖析附带答案详解
评论
0/150
提交评论