matlab中遇到的一些问题.doc_第1页
matlab中遇到的一些问题.doc_第2页
matlab中遇到的一些问题.doc_第3页
matlab中遇到的一些问题.doc_第4页
matlab中遇到的一些问题.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1什么是Gaussian拟合?:#FangQ(Qianqian.FangDartmouth.Edu),2002/9/23, BigGreen/MathTools # 高斯拟合(Gaussian Fitting)即使用形如: Gi(x)=Ai*exp(x-Bi)2/Ci2) 的高斯函数对数据点集进行函数逼近的拟合方法。 其实可以跟多项式拟合类比起来,不同的是多项式拟合是用幂函数系, 而高斯拟合是用高斯函数系。 使用高斯函数来进行拟合,优点在于计算积分十分简单快捷。这一点 在很多领域都有应用,特别是计算化学。著名的化学软件Gaussian98 就是建立在高斯基函数拟合的数学基础上的。2如何在给定句柄的axis里绘图?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/12, SMTH/MathTools # plot(data,parent,haxis); 或者 hbar=bar(data); set(hbar,parent,haxis);3)由Matlab符号运算得到的公式怎么才能将数据代进去运算?:#ramjet (德芙)2002/3/3, SMTH/MathTools # 使用subs(),或先将值赋予一个符号变量,然后用eval()5)在Matlab中如何求最值点?如何求一维数组的极值?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/18, SMTH/MathTools# 最值: 一维或多维数组最值用max(data(:) 如果想返回最值所在的位置,用Y,I=max(data):#FangQ(Qianqian.FangDartmouth.Edu), 2001/4/21,UESTC/Math# 极值: data是你的数据, find(diff(sign(diff(data)=-2)+1 找到极大值的位置 find(diff(sign(diff(data)=2)+1 找到极小值的位置 data(find(diff(sign(diff(data)=-2)+1)和 data(find(diff(sign(diff(data)=2)+1) 返回的是极大值和极小值6)Matlab中如何作线性拟合/线性回归/多元线性回归?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21, BigGreen/MathTools # 即用y=a*x+b来拟合一组数据x1,y1,x2,y2xn,yn matlab中使用polyfit x=data(:,1); y=data(:,2); p=polyfit(x,y,1); p(1)为斜率a,p(2)为截距b 多元线性回归即用y=a1*x1+a2*x2+.+am*xm来拟合数据点x1i,x2i,xmi,yi (i=1n) |x11,x21,xm1| A=|x12,x22,xm2| | | |x1n,x2n,xmn| Y=y1,y2,y3,yn 则系数a1,a2,am=pinv(A)*Y 在matlab中使用 coeff=AY 则可以得到最小二乘意义上的拟合系数7)Matlab中如何作圆回归?:#Peter Boettcher (),2002/5/16, comp.soft-sys.matlab# Q5.5: How can I fit a circle to a set of XY data? = An elegant chunk of code to perform least-squares circle fitting was written by Bucher Izhak and has been floating around the newgroup for some time. The first reference to it that I can find is in: function xc,yc,R,a = circfit(x,y) %CIRCFIT Fits a circle in x,y plane % % XC, YC, R, A = CIRCFIT(X,Y) % Result is center point (yc,xc) and radius R.A is an % optional output describing the circles equation: % % x2+y2+a(1)*x+a(2)*y+a(3)=0 % by Bucher izhak 25/oct/1991 n=length(x); xx=x.*x; yy=y.*y; xy=x.*y; A=sum(x) sum(y) n;sum(xy) sum(yy). sum(y);sum(xx) sum(xy) sum(x); B=-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y); a=AB; xc = -.5*a(1); yc = -.5*a(2); R = sqrt(a(1)2+a(2)2)/4-a(3); Tom Davis provided a more sophisticated approach that works for more cases in and Code included.8)Matlab中如何绘制箭头?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21, SMTH/MathTools # 到/matlabcentral/fileexchange/index.jsp 2-D Plotting and Graphics中查找arrow.m,或者 /matlabcentral/spotlight/arrows.shtml /jec/matcomp/matcompmfiles/mfiles.html9)Matlab中如何作二维数据的插值?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21, BigGreen/MathTools # 对于一维、二维、三维规则数据点阵使用interp1/interp2/interp3, 二维、三维非规则数据用griddata/griddata310)Matlab中如何绘制三维数据阵?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21, BigGreen/MathTools # 如果使用matlab,打开帮助窗口,在目录树上找到 MATLABUsing Matlab 3-D Visualization: Volume Visualization Techniques 如果图形复杂,建议使用Tecplot,参见Tecplot手册中数据格式,将你 的三维数据读入Tecplot,双击zone,可以设置mesh/contour/surface transparency等。 在Field菜单中有3D Iso-surface Details和3D Slice Details,可以绘制等值 面和任意平面的截面图。11)Matlab中如何注解一大段代码?:#hyphone,2002/7/6, SMTH/MathTools # 注释大段代码选中代码,Ctrl+R;取消注释,选中代码,Ctrl+T。 或者用Edit菜单或者右键弹出中的注释。:#misc,2002/6/21, SMTH/MathTools # if(0) 大段的代码 end12)Matlab中如何计算程序运行的时间?:#misc,2002/6/21, SMTH/MathTools # tic your_code; toc 或者使用 t=cputime; your_operation; cputime-t13)Matlab中如何改变默认的工作路径?:#SindyGong, 2002/4/7, SMTH/MathTools # 编辑一个startup.m文件,其中cd yourpath 或者在X:matlabtoolboxlocalmatlabrc.m的最后添加cd yourpath 参见: /support/solutions/data/25164.shtml14)Matlab如何改变默认的图形字体?:#comp.soft-sys.matlab FAQ# 编辑一个startup.m文件,其中 set(0,DefaultObjectnamePropertyName,Value) 或者在X:matlabtoolboxlocalmatlabrc.m的最后添加 set(0,DefaultObjectnamePropertyName,Value)15)如何在Matlab中实现交互操作?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 如果只在命令窗口进行交互操作,请参见demo中的例子,主要是 通过input命令和pause/clear/disp等实现的,还有一些窗口资源可以使 用: uigetfile,uiputfile,uiwait,uisetcolor,uisetfont, uiopen,uisave inputdlg,msgbox,helpdlg,questdlg,warndlg,errordlg16)Matlab中为什么只能在小数点后显示四位?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 用format命令来改变命令窗口数字的显示格式和精度,但不会影 响matlab的计算精度,matlab的矩阵运算默认都是双精度浮点型运算。17)Matlab如何在命令窗口按照格式输出?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,SMTHTools # fprintf(1,your_format_string,var1,var2,);18)如何在Matlab中画隐函数曲线?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 在/matlabcentral/fileexchange/index.jsp 查找implicit,会找到一个Arthur Jutan写的implot.m Mathematica中绘制隐函数用ImplicitPlot 或者ImplicitPlot3D Maple中为implicitplot(),implicitplot3d() 参见 /fangq/MATH/download/source/ ImplicitPlot3D.htm19)Matlab中什么函数可以删除矩阵的某一行或列?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # A(j,:)=; %删除A的第j行 A(:,i)=; %删除A的第i列20)Matlab中能开的最大数组是由什么决定的?:# chenft (mike),2002/6/1, SMTH/MathTools # I have had similar problems. Below is an explanation I received from Ian Boyd from Mathworks (just giving credit where credit is due) that explains whats happening. You solution is to run matlab with the -nojvm mode. The heap memory system in JAVA consists of data and handle elements. When you allocate a variable you get a handle and data. As long as data has an associated handle, the JVM considers it valid and will not clean it up. However, when you call the clear function in MATLAB, all handles are destroyed, and the data associated is now invalid. This means that the JAVA engine can free up that data (garbage collection), but does not mean that it will clean it up at that moment. Calling the PACK command encourages JAVA to run the garbage collector and de-fragment the memory. But it does not force it to (This is part of the JAVA design). Even though the memory is freed on the heap, it is not actually free to the OS, it is only free to the JVM. Here is one way to think of it: MATLAB JAVA OS MATLAB runs on JAVA (virtual machine), and Java runs on the OS (physical machine). So when MATLAB is running in JAVA mode memory allocations are requested from the JRE, not the OS. One problem you may be running into is that the default maximum JAVA heap size is relatively low ( java.lang.Runtime.getRuntime.totalMemory java.lang.Runtime.getRuntime.freeMemory When the free memory hits zero, Java will double the heap size (up to the maximum setting). If you choose to run without Java, you will remove the overhead of the middle man, but you will also lose some MATLAB functionality (mostly graphics and the Editor). You will still have most of the computational power though. Without JAVA, memory management will come directly from the OS, and a CLEAR operation will result in memory being freed back to the OS.21)如何在Matlab中添加新的工具箱?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 如果是Matlab安装光盘上的工具箱,重新执行安装程序,选中即可。 如果是单独下载的工具箱,一般情况下仅需要把新的工具箱解压到某 个目录,然后用addpath(对于多个目录的使用genpath()或者pathtool添 加工具箱的路径,然后用which newtoolbox_command.m来检验是否可 以访问。如果能够显示新设置的路径,则表明该工具箱可以使用了。 具体请看工具箱自己代的README文件。22)如何读写Matlab的.mat文件?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 文件结构参见: http:/www.mathworks.de/access/helpdesk/help/pdf_doc/matlab/ matfile_format.pdf /support/solutions/data/8757.shtml /pub/tech-support/solutions/s8757/ readmemat.txt 建议使用matlab自己提供的函数来读写简单安全,或者参考: /fangq/MATH/download/ source/mat_file.txt 来自matlab的c math library23)如何得到contour线上的坐标点?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # lcount=5; c,h=contour(peaks,lcount); x=get(h,xdata); y=get(h,ydata); 这里得到的x和y都是cell数组,用x1/y1来得到每条线上的坐标对, 注意,每条线的最后一个数据是NaN24)如何将Matlab绘制的三维网格图帖到word里?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # 如果需要位图,好处是所见即所得,坏处是图像精度差,不能放缩: 1.用拷屏 Alt+PrintScreen 2.在图形窗口菜单EditCopy Options.选择Bitmap,可以 选择透明背景,然后EditCopy Figure 如果需要拷贝矢量图: 在图形窗口菜单EditCopy Options.选择Metafile,然后 EditCopy Figure,在Word中粘贴 经常地,按照Metafile方式粘贴的图片曲线会出现锯齿,最好的方式是 使用eps文件: 1.将需要拷贝的图作为当前窗口 2.再转换到matlab命令窗口,print -deps filename.eps 3.-deps还可以用depsc,deps2,depsc2 4.在word中插入图片,选中该eps,如果是word 2000以前版本 ,不会显示图片内容,但可以打印,word XP即可显示,又可打印。 5.如果不满意,可以在word中双击编辑,如果安装有Adobe Illustrator等矢量图像编辑软件,也可以进行编辑。25)请问可以查看Matlab中函数的源代码吗?:#FangQ(Qianqian.FangDartmouth.Edu),2002/6/21,BigGreen/MathTools # Matlab除了buildin函数和mex/dll文件看不到原码,其他如工具箱等都可 以直接看到代码,首先确认该文件安装在matlab中,即which filename.m存在,然后可以edit filename.m26).Matlab有没有求矩阵行数/列数/维数的函数?:#FangQ(Qianqian.F),2002/6/21,BigGreen/MathTools # ndims(A)返回A的维数 size(A)返回A各个维的最大元素个数 length(A)返回max(size(A) m,n=size(A)如果A是二维数组,返回行数和列数 nnz(A)返回A中非0元素的个数27).Matlab中如何中断运算?:#FangQ(Qianqian.F),2002/6/21,BigGreen/MathTools # 在命令窗口按Ctrl+C,在UNIX/LINUX会立即中断运算,在Windows可 能由于操作系统的原因,有时会出现死机和等待的情况。28).Matlab中有没有画圆或椭圆的函数?:#FangQ(Qianqian.F),2002/6/21,BigGreen/MathTools # 没有,Matlab没有提供直接绘圆的图元函数,需要自己写代码,其实 就两句: sita=0:pi/20:2*pi; plot(r*cos(sita),r*sin(sita); %半径为r的圆 plot(a*cos(sita+fi),b *sin(sita+fi); %椭圆 如果是单位圆,可以使用rectangle(Curvature, 1 1)29).Matlab下如何定义整形:#修改:fhorse (马不停蹄),2002/6/21,SMTH/MathTools # Matlab默认的矩阵数据结构都是双精度浮点型,即64位来表示一个数 字,大多数的函数和操作都定义在double数据结构,如果你需要 把double的数据转换为整形,然后再参与运算,需要使用 double(int32(x)或者floor/round/ceil等函数 如果为了节省内存,只进行赋值、打印等简单操作,可以参 见uint8/uint16/uint32命令的帮助30).Matlab如何产生均匀分布的白噪声?:#misc,2002/6/21,SMTH/MathTools # help rand 均匀分布百噪声 help randn高斯分布百噪声31).在Matlab中debug的时候能否跟踪变量的?:#FangQ(Qianqian.F),2002/6/21,BigGreen/MathTools # 可以,如果使用medit,设置断点后可以用鼠标移到所看的变量上,显 示当前的值,或者在命令窗口打该变量名直接回车。如果在代码中实 现调试断点等功能,参 见dbstop,dbcont,dbstep,dbclear,dbtype,dbstack,dbup,dbdown,dbstatus, dbquit32).请问在Matlab中怎样输入特殊符号啊或者上标、下标?:#FangQ(Qianqian.F),southerner(笑着),2002/6/6,SMTH/MathTools# matlab的text/title/xlabel/ylabel对象支持简单的TeX排版语法,如希腊字 母,上下标等例如 text(0.5,0.5,alphabeta_2);33).Matlab中如何后台运行一个DOS程序?:#FangQ(Qianqian.F), 2002/6/4. BigGreen/en_Matlab# 这里是一个后台执行一个需要外部输入的DOS命令的例子,需要的输 入实事先都写在同目录下的input.txt文件中: dos(myexe input.txt &)34).Matlab如何加载输入文件(批处理模式) ?:#翻译自:comp.sys-soft.Matlab FAQ. BigGreen/en_Matlab# PC上可以使用matlab /r参数来在matlab启动的时候直接加载运行m文件 ,在UNIX上,使用 matlab MyOutputFile 来外部执行MyMFile, 以上执行方式都可以通过脚本文件实现批处理35).Matlab如何启动时执行规定的文件?:#FangQ(Qianqian.F), 2002/5/29.BigGreen/en_Matlab# 参见上一个问题的回答36).如何在Matlab GUI中使用图形背景?:#FangQ(Qianqian.F), 2002/5/29.BigGreen/en_Matlab# 这是一个简单的例子: A,map=imread(yourimg.gif); imagesc(A) colormap(map) set(gca,position,0 0 1 1) axis off ax2=axes(position,0.2,0.2,0.6,0.6); plot(rand(1,10),parent,ax2); set(ax2,color,none) 37).大量数据点Matlab绘图为什么很慢?:#FangQ(Qianqian.F), 2002/6/22.BigGreen/en_Matlab# 1.首先看能否用已有函数对整个矩阵绘图,比 如mesh/plot3/trimesh等 2.如果必须一点一点/或者一条线一条线的添加,最好作如下 设置: doublebuffer=on erasemode=none backingstore=off rendereropengl 以及参考MathWorks对于高速绘图的tips: /support/tech-notes/v5/1200/1203.shtml,38).Matlab中如何求解广义积分?即积分限到有无穷的或者有奇异点的积分(瑕积分)?:#FangQ(Qianqian.Fangdartmouth.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论