matlab常见问题合集.docx
- 文档编号:29810471
- 上传时间:2023-07-27
- 格式:DOCX
- 页数:18
- 大小:25.83KB
matlab常见问题合集.docx
《matlab常见问题合集.docx》由会员分享,可在线阅读,更多相关《matlab常见问题合集.docx(18页珍藏版)》请在冰豆网上搜索。
matlab常见问题合集
MATLAB常见问题集
2007-05-2817:
08
Matlab的常见问题
===================================
1).Matlab6.X在Windows2000/XP上无法启动
2).我有一组x,y,z值,非规则排列,如何在Matlab中绘图?
3).如何在给定句柄的axis里绘图?
4).由Matlab符号运算得到的公式怎么才能将数据代进去运算?
5).在Matlab中如何求最值点?
如何求一维数组的极值?
6).Matlab中如何作线性拟合/线性回归/多元线性回归?
7).Matlab中如何作圆回归?
8).Matlab中如何绘制箭头?
9).Matlab中如何作二维数据的插值?
10).Matlab中如何绘制三维数据阵?
11).Matlab中如何注解一大段代码?
12).Matlab中如何计算程序运行的时间?
13).Matlab中如何改变默认的工作路径?
14).Matlab如何改变默认的图形字体?
15).如何在Matlab中实现交互操作?
16).Matlab中为什么只能在小数点后显示四位?
17).Matlab如何在命令窗口按照格式输出?
18).如何在Matlab中画隐函数曲线?
19).Matlab中什么函数可以删除矩阵的某一行或列?
20).Matlab中能开的最大数组是由什么决定的?
21).如何在Matlab中添加新的工具箱?
22).如何读写Matlab的.mat文件?
23).如何得到contour线上的坐标点?
24).如何将Matlab绘制的三维网格图帖到word里?
25).请问可以查看Matlab中函数的源代码吗?
26).Matlab有没有求矩阵行数/列数/维数的函数?
27).Matlab中如何中断运算?
28).Matlab中有没有画圆或椭圆的函数?
29).Matlab下如何定义整形
30).Matlab如何产生均匀分布的白噪声?
31).在Matlab中debug的时候能否跟踪变量的?
32).请问在Matlab中怎样输入特殊符号啊或者上标、下标?
33).Matlab中如何后台运行一个DOS程序?
34).Matlab如何加载输入文件(批处理模式).?
35).Matlab如何启动时执行规定的文件?
36).如何在MatlabGUI中使用图形背景?
37).大量数据点Matlab绘图为什么很慢?
38).Matlab中如何求解广义积分?
即积分限到有无穷的或者有歧
异点的积分(瑕积分)?
39).为什么我的Matlab程序这么慢?
40).Matlab中如何作线性拟合/线性回归/多元线性回归?
>*****************************************************************************<
Matlab的常见问题
>*****************************************************************************<
===================================
1)Matlab6.X在Windows2000/XP上无法启动
:
#highsun,2001/3/2,SMTH/NewSoftware#
其实也出来很久了,不知大家有没有注意到.
虽然是针对繁体中文系统的,我试过在简体
中文系统下一样可以用。
SolutionNumber:
26990
DateLastModified:
2001-01-30
Product:
MATLAB6.0==>CurrentVersion
Platform:
Windows
ProblemDescription
WhydoIencounterproblemswhenrunningMATLAB6.0(R12)onHebrew
or
TraditionalChinese(Taiwan)Windows?
ItrytostartMATLABbutafter
thesplashscreendisappears,MATLABexits.
PLEASENOTE:
ThissolutiononlyappliestoMATLAB6.0.Ifyouhavea
similarproblemwithMATLAB5.0ortheStudentEditionofMATLAB5.0,
seesolution7213.
Solution:
Thisproblemiscausedbyabuginoneofthefontpropertiesfilesweship
withMATLAB.Thefont.propertiesfileisusedbyJavatomapthestandard
Javafontnamestosystemfontsforaparticularlanguageoperatingsystem.
However,wemadeafewassumptionsthatdonotholdfortheHebrewor
TraditionalChineseWindows,causingthisproblem.
Wehavecreatedafixedversionofthemwt.jarfilethatyoucanuseto
correctthis.Tousethefix,firstrenameyourmwt.jarfileasmwt.old.
Thisfileisfoundinthe$MATLAB\java\jardirectory,where$MATLABisyour
MATLABrootdirectory.Thendownloadthenewermwt.jarfilefrom:
ftp:
//
andplaceitinyour$MATLAB\java\jardirectrory.ThenrestartMATLAB;
thisshouldcorrecttheproblemyou'reseeing.
2)我有一组x,y,z值,非规则排列,如何在Matlab中绘图?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/12,BigGreen/MathTools#
参见第一节问题7)
3)如何在给定句柄的axis里绘图?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/12,SMTH/MathTools#
plot(data,'parent',haxis);
或者
hbar=bar(data);
set(hbar,'parent',haxis);
4)由Matlab符号运算得到的公式怎么才能将数据代进去运算?
:
#ramjet(德芙)2002/3/3,SMTH/MathTools#
使用subs(),或先将值赋予一个符号变量,然后用eval()
5)在Matlab中如何求最值点?
如何求一维数组的极值?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/18,SMTH/MathTools#
最值:
一维或多维数组最值用max(data()
如果想返回最值所在的位置,用[Y,I]=max(data)
:
#FangQ(Qianqian.Fang@Dartmouth.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.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
即用y=a*x+b来拟合一组数据{{x1,y1},{x2,y2}…{xn,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=1~n)
|x11,x21,…xm1|
A=|x12,x22,…xm2|
|……………|
|x1n,x2n,…xmn|
Y={y1,y2,y3,…,yn}'
则系数{a1,a2,…,am}'=pinv(A)*Y
在matlab中使用
coeff=A\Y
则可以得到最小二乘意义上的拟合系数
7)Matlab中如何作圆回归?
:
#PeterBoettcher(boettcher@ll.mit.edu),2002/5/16,comp.soft-sys.matlab#
Q5.5:
HowcanIfitacircletoasetofXYdata?
=================================================
Anelegantchunkofcodetoperformleast-squarescirclefittingwas
writtenbyBucherIzhakandhasbeenfloatingaroundthenewgroupfor
sometime.ThefirstreferencetoitthatIcanfindisin:
function[xc,yc,R,a]=circfit(x,y)
%CIRCFITFitsacircleinx,yplane
%
%[XC,YC,R,A]=CIRCFIT(X,Y)
%Resultiscenterpoint(yc,xc)andradiusR.Aisanoptional
%outputdescribingthecircle'sequation:
%
%x^2+y^2+a
(1)*x+a
(2)*y+a(3)=0
%byBucherizhak25/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=A\B;
xc=-.5*a
(1);
yc=-.5*a
(2);
R=sqrt((a
(1)^2+a
(2)^2)/4-a(3));
TomDavisprovidedamoresophisticatedapproachthatworksformore
casesinandCodeincluded.
8)Matlab中如何绘制箭头?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,SMTH/MathTools#
到
2-DPlottingandGraphics中查找arrow.m,或者
http:
//www.math.umd.edu/~jec/matcomp/matcompmfiles/mfiles.html
9)Matlab中如何作二维数据的插值?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
对于一维、二维、三维规则数据点阵使用interp1/interp2/interp3,
二维、三维非规则数据用griddata/griddata3
10)Matlab中如何绘制三维数据阵?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
如果使用matlab,打开帮助窗口,在目录树上找到
MATLAB\UsingMatlab\3-DVisualization:
VolumeVisualizationTechniques
如果图形复杂,建议使用Tecplot,参见Tecplot手册中数据格式,将你
的三维数据读入Tecplot,双击zone,可以设置mesh/contour/surface
transparency等。
在Field菜单中有3DIso-surfaceDetails和3DSliceDetails,可以绘制等值
面和任意平面的截面图。
11)Matlab中如何注解一大段代码?
:
#misc,2002/6/21,SMTH/MathTools#
if(0)
大段的代码
end
12)Matlab中如何计算程序运行的时间?
:
#misc,2002/6/21,SMTH/MathTools#
tic
your_code;
toc
或者使用
t=cputime;
your_operation;
cputime-t
13)Matlab中如何改变默认的工作路径?
:
#SindyGong,2002/4/7,SMTH/MathTools#
编辑一个startup.m文件,其中cdyourpath
或者在X:
\matlab\toolbox\local\matlabrc.m的最后添加cdyourpath
参见:
14)Matlab如何改变默认的图形字体?
:
#comp.soft-sys.matlabFAQ#
编辑一个startup.m文件,其中
set(0,'DefaultObjectnamePropertyName',value)
或者在X:
\matlab\toolbox\local\matlabrc.m的最后添加
set(0,'DefaultObjectnamePropertyName',value)
15)如何在Matlab中实现交互操作?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
如果只在命令窗口进行交互操作,请参见demo中的例子,主要是
通过input命令和pause/clear/disp等实现的,还有一些窗口资源可以使
用:
uigetfile,uiputfile,uiwait,uisetcolor,uisetfont,uiopen,uisave
inputdlg,msgbox,helpdlg,questdlg,warndlg,errordlg
16)Matlab中为什么只能在小数点后显示四位?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
用format命令来改变命令窗口数字的显示格式和精度,但不会影
响matlab的计算精度,matlab的矩阵运算默认都是双精度浮点型运算。
17)Matlab如何在命令窗口按照格式输出?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,SMTHTools#
fprintf(1,"your_format_string",var1,var2,…);
18)如何在Matlab中画隐函数曲线?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
在
查找implicit,会找到一个ArthurJutan写的implot.m
Mathematica中绘制隐函数用ImplicitPlot[]
或者ImplicitPlot3D[]
Maple中为implicitplot(),implicitplot3d()
参见
http:
//engineering.dartmouth.edu/~fangq/MATH/download/source/Implicit
Plot3D.htm
19)Matlab中什么函数可以删除矩阵的某一行或列?
:
#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools#
A(j,=[];%删除A的第j行
A(:
i)=[];%删除A的第i列
20)Matlab中能开的最大数组是由什么决定的?
:
#chenft(mike),2002/6/1,SMTH/MathTools#
Ihavehadsimilarproblems.BelowisanexplanationIreceivedfromIan
Boyd
fromMathworks(justgivingcreditwherecreditisdue)thatexplains
what'shappening.Yousolutionistorunmatlabwiththe-nojvmmode.
"TheheapmemorysysteminJ***Aconsistsofdataandhandleelements.
Whenyouallocateavariableyougetahandleanddata.Aslongasdata
hasan
associatedhandle,theJVMconsidersitvalidandwillnotcleanitup.
However,whenyoucalltheclearfunctioninMATLAB,allhandlesare
destroyed,andthedataassociatedisnowinvalid.Thismeansthatthe
J***A
enginecanfreeupthatdata(garbagecollection),butdoesnotmean
thatitwillcleanitupatthatmoment.
CallingthePACKcommandencouragesJ***Atorunthegarbagecollector
andde-fragmentthememory.Butitdoesnotforceitto(Thisispart
oftheJ***Adesign).Eventhoughthememoryis'freed'ontheheap,
itisnotactuallyfreetotheOS,itisonlyfreetotheJVM.Here
isonewaytothinkofit:
[MATLAB]
[J***A]
[OS]
MATLABrunsonJ***A(virtualmachine),andJavarunsontheOS(physical
machine).SowhenMATLABisrunninginJ***Amodememoryallocations
arerequestedfromtheJRE,nottheOS.
OneproblemyoumayberunningintoisthatthedefaultmaximumJ***Aheap
sizeisrelativelylow(<=64M,sothatisallthememoryonesession
ofMATLABwillevergetonyoursystem.
Thegoodnewsisthatyoucanincreasethisvalue.Youwillneedtocreate
ajava.optsfilein$MATLAB/bin/$ARCH(orinthecurrentdirectorywhen
you
startMATLAandputthefollowingcommand:
%%%BEGINCODE%%%
maxHeapSize=268435456
%%%ENDCODE%%%
Thiswillgiveyou256MBofJVMmemoryandyoucan
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab 常见问题
![提示](https://static.bdocx.com/images/bang_tan.gif)