matlab简介3matlabm-file程式与多项式函数

matlab简介3matlabm-file程式与多项式函数

ID:36315694

大小:267.50 KB

页数:52页

时间:2019-05-09

matlab简介3matlabm-file程式与多项式函数_第1页
matlab简介3matlabm-file程式与多项式函数_第2页
matlab简介3matlabm-file程式与多项式函数_第3页
matlab简介3matlabm-file程式与多项式函数_第4页
matlab简介3matlabm-file程式与多项式函数_第5页
资源描述:

《matlab简介3matlabm-file程式与多项式函数》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Whatisanm-file?Anm-fileisafilewithextension.mItcanbeusedtostorecommandsMatlabreadsandexecutesthecommandsinanm-fileifyoutypethenameofthefileinthecommandwindowUseanordinarytexteditorandsavethefileasfilename.mChoose’newfile’undertheFileMenuDifferentwaysofcreatingm-filesInthefirstcasethefun

2、ctioninv(A)isusedtofindtheinverse.Thisisthenmultipliedbyb.TheMatlabcodeforthisoperationisInthesecondcaseleft-divisionisperformedstraightawaywiththecommandX=9.25004.25002.7500X=9.25004.25002.7500ExampleExamplesolvetime.mA=rand(1000,1000);%Createsarandom%matrixAb=rand(1000,1);%Createsaran

3、dom%vectorbdet(A)%CalculatesthedeterminantofAtic,%Startsthetime-watchx=inv(A)*b;%Solvesthesystemtoc%Stopsthewatchtic,y=Ab;toc%Solvesandtimesthe%systemwithleftdivisionlapsed_time=1.2820elapsed_time=0.5310以下的tutex1.m档是一个简易绘图程式做为示范使用M-file%M-file,tutex1.m%SimpleplotforillustrationofusingM

4、-file.%简易绘图以做为示范使用M-filex=linspace(0,2*pi,20);y=sin(x);plot(x,y,'r+')xlabel('x-value')ylabel('y-value')title('2Dplot')WhenyouwritesomethinginMatlab’scommandwindow,thefollowingthingsarecheckedinturn:1.Istheresuchavariableintheworkspace?2.Isthereanm-filecalledthatthinginthecurrentdirector

5、y?3.Isthereanm-filecalledthatsomewhereelse?WhenMatlabsearchesforthem-fileitlooksinspecificfolders,itssearchpath.IfthefolderisnotaddedtothepathMatlabcannotrunyourscript.HowtomakesureMatlabfindsyourm-fileChangecurrentdirectoryusingthecdcommandorbyclickingintheDirectorypanelSelectthe’SetPa

6、th’optionintheFilemenuTypeoneofthefollowingcommandsinthecommandwindow:addpathC:ProgramMatlab6k5myfilespath(path,’C:ProgramMatlab6k5myfiles’)>>cdwufilemy_work%切换至目录wufilemy_work>>cd%如果只用cd则会显示目前的目录c:WUFILEMY_WORK>>dir%列出目录下的档案.tutex1.mtutex2.m..test.txt>>deletetest.txt%删除test

7、.txt>>path(path,'c:wufilemy_work')%将自己的目录wufilemy_work加在%MATLAB的搜寻路径之后>>path('c:wufilemy_work',path)%将自己的目录wufilemy_work加在%MATLAB的搜寻路径之前WhatisafunctionAfunctionisanm-filebeginningwiththeword’function’Afunctionhasauser-specifiedinputandoutputAfunctionhasitsown’local’work

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。