griddata调用方法 matlab griddata v4

griddata 调用方法:ZI = griddata(x,y,z,XI,YI)[XI,YI,ZI] = griddata(x,y,z,XI,YI)[...] = griddata(...,method)[...] = griddata(...,method,options)method 的值 为'linear' -- 则,以三角形为基础的线性内插'cubic' -- 则,以三角形为基础的三次方程内插'nearest' -- 则,用最邻近的点 内插'v4'-- -- 则,MATLAB 4 格点样条函数内插默认'linear' 线性内插三角形为基础,就是按Delaunay方法先找出内插点四周的3个点,构成三角形,内插点在三角形内。然后线性内插,或三次方程内插。'cubic' 和 'v4' 插值结果构成的曲面较光滑,'linear'和 'nearest' 插值结果构成的曲面不光滑不连续。

知道一系列点的坐标如下(1.486,3.059,0.1);(2.121,4.041,0.1);(2.570,3.959,0.1);(3.439,4.396,0.1);(4.505,3.012,0.1);(3.402,1.604,0.1);(2.570,2.065,0.1);(2.150,1.970,0.1);(1.794,3.059,0.2);(2.121,3.615,0.2);(2.570,3.473,0.2);(3.421,4.160,0.2);(4.271,3.036,0.2);(3.411,1.876,0.2);(2.561,2.562,0.2);(2.179,2.420,0.2);(2.757,3.024,0.3);(3.439,3.970,0.3);(4.084,3.036,0.3);(3.402,2.077,0.3);(2.879,3.036,0.4);(3.421,3.793,0.4);(3.953,3.036,0.4);(3.402,2.219,0.4);(3.000,3.047,0.5);(3.430,3.639,0.5);(3.822,3.012,0.5);(3.411,2.385,0.5);(3.103,3.012,0.6);(3.430,3.462,0.6);(3.710,3.036,0.6);(3.402,2.562,0.6);(3.224,3.047,0.7);(3.411,3.260,0.7);(3.542,3.024,0.7);(3.393,2.763,0.7)怎样用MATLAB绘制成三维曲面呢?使用griddata插值A=[1.486,3.059,0.1;2.121,4.041,0.1;2.570,3.959,0.1;3.439,4.396,0.1;4.505,3.012,0.1;3.402,1.604,0.1;2.570,2.065,0.1;2.150,1.970,0.1;1.794,3.059,0.2;2.121,3.615,0.2;2.570,3.473,0.2;3.421,4.160,0.2;4.271,3.036,0.2;3.411,1.876,0.2;2.561,2.562,0.2;2.179,2.420,0.2;2.757,3.024,0.3;3.439,3.970,0.3;4.084,3.036,0.3;3.402,2.077,0.3;2.879,3.036,0.4;3.421,3.793,0.4;3.953,3.036,0.4;3.402,2.219,0.4;3.000,3.047,0.5;3.430,3.639,0.5;3.822,3.012,0.5;3.411,2.385,0.5;3.103,3.012,0.6;3.430,3.462,0.6;3.710,3.036,0.6;3.402,2.562,0.6;3.224,3.047,0.7;3.411,3.260,0.7;3.542,3.024,0.7;3.393,2.763,0.7];x=A(:,1);y=A(:,2);z=A(:,3);scatter(x,y,5,z)%散点图figure[X,Y,Z]=griddata(x,y,z,linspace(1.486,4.271)',linspace(1.604,4.276),'v4');%插值pcolor(X,Y,Z);shading interp%伪彩色图figure,contourf(X,Y,Z) %等高线图figure,surf(X,Y,Z)%三维曲面
x = rand(1,12);y = rand(1,12);z = rand(1,12); % now use some random z axis dataxi = linspace(min(x),max(x),30);        % x interpolation pointsyi = linspace(min(y),max(y),30);        % x interpolation points[Xi,Yi] = meshgrid(xi,yi);              % create grid of x and yZi = griddata(x,y,z,Xi,Yi);             % grid the data at Xi,Yi points% Zi = griddata(x,y,z,Xi,Yi, 'linear')          % same as above(default)% Zi = griddata(x,y,z,Xi,Yi, 'cubic')           % triangle based cubic interpolation% Zi = griddata(x,y,z,Xi,Yi, 'nearest') % triangle based nearest neighbor% Zi = griddata(x,y,z,Xi,Yi, 'invdist')         % inverse distance methodmesh(Xi,Yi,Zi)hold onplot3(x,y,z, 'ko')      % show original data as wellhold offtitle('Figure 18.10: Griddata Example') 

【问题描述】

有三列数字保存于excel表格中,现在想把这三列数字画成三维图。

19.91058209.3531220
19.88966209.6685220.9091
19.86895209.987221.8182
19.84847210.3088222.7273
19.82822210.6338223.6364
19.80821210.9625224.5455
19.78843211.2948225.4545
19.7689211.631226.3636
19.74961211.9712227.2727
19.73058212.3158228.1818
19.7118212.665229.0909
19.69328213.0191230
19.67503213.3783230.9091
19.65705213.7431231.8182
19.63935214.1137232.7273
19.62194214.4907233.6364
19.60482214.8746234.5455
19.588215.266235.4545
19.57148215.6655236.3636
19.55529216.074237.2727
19.53942216.4924238.1818
19.52389216.9218239.0909
19.5087217.3637240
19.49389217.8194240.9091
19.47955218.2883241.8182
19.46577218.7697242.7273
19.45265219.2627243.6364
19.44026219.7668244.5455
19.4287220.2813245.4545
19.41802220.8059246.3636
19.40831221.34247.2727
19.39963221.8833248.1818
19.39204222.4354249.0909
19.38561222.9961250
19.38039223.5649250.9091
19.37644224.1416251.8182
19.37383224.726252.7273
19.37259225.3179253.6364
19.37279225.9169254.5455
19.37448226.523255.4545
19.3777227.1359256.3636
19.38251227.7555257.2727
19.38895228.3815258.1818
19.39707229.0139259.0909
19.40691229.6525260

【解决方法】

只有三类数字是不可能画出三维图的,需要插值转换一下,才能画出网格图或者更好的插值方法得到更光滑的曲面图。

【Matlab代码】

clc; clear all; close all;
A=xlsread('D:BackupMyDocumentsMATLABdata.xls');%读入数据
x=A(:,1);y=A(:,2);z=A(:,3);

t1=linspace(min(x),max(x));
t2=linspace(min(y),max(y));
[X,Y]=meshgrid(t1,t2);
griddata调用方法 matlab griddata v4
Z=griddata(x,y,z,X,Y,'v4');
figure,surf(X,Y,Z),axis([19.37,19.92,209.3,229.7,220,260]);%三维曲面
xlabel('sigma/mm');grid on;
ylabel('Maximum Stress/MPa');grid on;
zlabel('h1/mm');grid on;
title('关系图');

【最终效果图】

  

爱华网本文地址 » http://www.413yy.cn/a/25101016/308428.html

更多阅读

Matlab 2012b下载地址及安装方法 matlab2012安装教程

Matlab 2012b下载地址及安装方法——简介本文给出Matlab 2012b的下载地址以及破解安装方法,破解方法可在百度文库直接搜到......安装文件及破解均可在我百度网盘分享的文件中找到Matlab 2012b下载地址及安装方法——下载地址

代理超人v4.10的使用方法 t racks v4.10 破解版

代理 代理ip“代理超人”是一个简单易用的代理搜索工具,可以保证我们随时有有效的代理可用。  “代理超人”是绿色软件,只需将压缩包解压后就可以使用了。软件运行后主界面如图1。标题栏显示了软件的版本和我电脑的IP地址。 图1

转载 用SOR方法解方程组计算方法matlab matlab中sor迭代法

原文地址:用SOR方法解方程组计算方法matlab作者:不再彷徨function [Lw,f]=fifth1(A,b)%输入方程左端系数和右端向量,输出SOR方法的迭代矩阵,%及另一个系数s=size(A);%方程组左端系数矩阵的大小ss=size(b);f=zeros(ss(1),ss(2));%定义一

Matlab中使用Plot函数动态画图方法总结 matlab中plot画图

Matlab除了强大的矩阵运算,仿真分析外,绘图功能也是相当的强大,静态画图没什么问题,由于Matlab本身的多线程编程缺陷,想要动态的画图,并且能够很好的在GUI中得到控制,还不是一件很容易的事情,下面总结几种方法。一. AXIS 移动坐标系这种方法

声明:《griddata调用方法 matlab griddata v4》为网友风中的摇曳分享!如侵犯到您的合法权益请联系我们删除