24小时热门版块排行榜    

查看: 706  |  回复: 2
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

rulin11

禁虫 (初入文坛)

本帖内容被屏蔽

已阅   关注TA 给TA发消息 送TA红花 TA的回帖

meatball1982

铜虫 (小有名气)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
dbb627:编辑内容 2011-12-10 19:54
dbb627(金币+2): 感谢应助 2011-12-10 20:01:46
rulin11(金币+2): 谢谢,你的回复,已经解决O(∩_∩)O~ 2011-12-12 14:45:37
下面的程度是基于1楼的思路写的,LZ可以按自己的数据生成具体的data.
基本的想法就是将对应于第个点的不同的Z值进行平均(也可以选用不同的方法得到不同的平均值。),通过拟合平均后的Z值,得到面,并将其画出。
我这里每个点会有5个不同的Z值,我看你的程序这个数是不一定的,没关系,程序中是可以自己判断,生成均值的。
看看有什么要求。具体还有其它的问题,可以再问。
CODE:
clear all
clc
% generate the numbers by :
% [url]http://muchong.com/bbs/viewthread.php?tid=3918964&fpage=1[/url]
n1=100;
n2=n1*10;
x=rand(n1,1);
y=rand(n1,1);
z=rand(n2,1);


x_new=repmat(x,[n2/n1,1]);
y_new=repmat(y,[n2/n1,1]);

% transform the data
data=[x_new';y_new';z']';

% calculate the mean value of each point.
for i=1:n1
     ind=[data(:,1)==x(i)&data(:,2)==y(i)];
     z_temp=data(ind,:);
     z_mean(i)=mean(z_temp(:,3));
end

% output the data.
x_temp=[min(x):(max(x)-min(x))/n1:max(x)];
y_temp=[min(y):(max(y)-min(y))/n1:max(y)];

[X,Y]=meshgrid(x_temp,y_temp);
Z = griddata(x,y,z_mean,X,Y);

mesh(X,Y,Z)
hold on
plot3(x,y,z_mean,'o')
% if u feel the original point is too chaos, u can ctrl+r the following
% codes
plot3(x_new,y_new,z,'r.')
hold off

% typed by : mm
% typed on : 19:28 2011-12-10

[ Last edited by dbb627 on 2011-12-10 at 19:54 ]
唉。还是学吧。
3楼2011-12-10 19:32:39
已阅   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 3 个回答

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

这个可以考虑将x,y重复对应点z值平均后再插值做图
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2011-12-09 09:46:56
已阅   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见