6-7m的atlab的程序设计.ppt

  1. 1、本文档共68页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
6-7m的atlab的程序设计

FWRITE ? FWRITE Write binary data to file. COUNT = FWRITE(FID,A,PRECISION) writes the elements of matrix A to the specified file, translating MATLAB values to the specified precision. The data are written in column order. COUNT is the number of elements successfully written. 例子: fid = fopen(magic5.bin,wb) fwrite(fid,magic(5),integer*4) 格式说明符 MATLAB的格式说明符包含5部分: % ——引导符(必需) +、-、0——标记(可选) 12.2——宽度与小数位数(可选) s、i、f、e、g——转换字符(必需) \n、%%——表控字符 特殊函数 fgetl,fgets 从文件读入行 feof 判断是否文件末尾 FGETL ? FGETL Read line from file, discard newline character. TLINE = FGETL(FID) returns the next line of a file associated with file identifier FID as a MATLAB string. The line terminator is NOT included. Use FGETS to get the next line with the line terminator INCLUDED. If just an end-of-file is encountered then -1 is returned. 例子:fid=fopen(fgetl.m); while 1 tline = fgetl(fid); if ~ischar(tline), break, end disp(tline) end fclose(fid); FGETS FGETS Read line from file, keep newline character. TLINE = FGETS(FID) returns the next line of a file associated with file identifier FID as a MATLAB string. The line terminator is included. Use FGETL to get the next line WITHOUT the line terminator. If just an end-of-file is encountered then -1 is returned. * * 第三节 Matlab结构化程序设计 计算机编程语言允许根据决策结构控制命令执行流程。控制流极其重要,因为它使用过去的计算影响将来的运算。 Matlab提供若干种决策或控制流结构,包括for循环、while循环和if-else-end结构等 这些结构经常包含大量的Matlab命令,故经常出现在M文件中,而不是直接加在Matlab提示符下。 matlab语言的程序结构与其它高级语言是一致的,分为: 1.顺序结构 -- 依次顺序执行程序的各条语句 2.循环结构 -- 被重复执行的一组语句,是计算机解决问题的主要手段。循环语句主要有: for — end ? while — end 3. 分支结构--根据一定条件来执行的各条语句。分支语句主要有: ? if — else — end ? swith ? try —catch 一、matlab的程序结构 (1)for循环 for循环允许一组命令以固定的和预定的次数重复。for循环的语法为: for i = 表达式 (表达式为一个向量) 可执行语句 e

文档评论(0)

liwenhua00 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档