2024年5月1日发(作者:)
[matlab数据拟合曲线]matlab获取等高线
的数据
篇一 : matlab获取等高线的数据
contour画出Z在向量v所有值处的等高线,如只想画出Z在i处的
等高线,则调用contour。如果没有图形,可以将contour3试试看。
另外,若想获得某一等高线处的具体数据,则用[c,h]=contour.其中
c中即包含等高线的信息,即对应Z=i处的xdata向量和ydata向量。
直接调用c就可以了,一般情况下xdata向量和ydata向量过长,显
示的时候是分段显示的dim1,表示接下来一段显示的
[xdata,ydata]的长度,如下:
C = [value1 ;
]
为方便查看,调用C’更清晰。
另外,读取任一matlab的fig图的数据的方法如下:
open; %打开图
Ih=findall;%获得曲线的句柄
xc=get;
yc=get;
另外注意:contour draws acontour plot of matrix Z, where Z is
interpreted as heights withrespect to the x-y plane. Z must be at least a
2-by-2 matrix. Thenumber of contour levels and the values of the contour
levels arechosen automatically based on the minimum and maximum
values of ranges of the x- and y-axis are[1:n] and [1:m], where
[m,n] = size.不要颠倒了!故调用时:
i=1;
for a4=-a:delta:a
k=1;
for a5=-b:delta:b
f=int0;%给二维矩阵f赋值,调用int0函数
k=k+1;
end
i=i+1;
end
a4=-a:delta:a;
a5=-b:delta:b;
meshgrid;%meshgrid产生网格
[c,h]=contour3;%将f转置一下才能和meshgrid相匹配!


发布评论