在非水平背景上生成数据

发布于 2024-08-31 13:52:11 字数 241 浏览 0 评论 0原文

我想制作一个非水平背景,然后使用 Matlab 生成一些测试数据。之前问这个问题的时候我并不清楚。因此,对于这个已经定义了 X 和 Y 的简单示例

for i = 1:10  
for j = 1:10  
f(i,j)=X.^2 + Y.^2  
end  
end  

,它将其绘制在平面上。我不想扭曲函数本身,但我希望它所在的表面是不水平的,在某种程度上或其他方面发生改变。我希望这更清楚一点。

I want to make an unlevel background and then generate some test data on that using Matlab. I was not clear when I asked this question earlier. So for this simple example

for i = 1:10  
for j = 1:10  
f(i,j)=X.^2 + Y.^2  
end  
end  

where X and Y have been already defined, it plots it on a flat surface. I don't want to distort the function itself, but I want the surface that it goes onto to be unlevel, changed by some degree or something. I hope that's a little clearer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永言不败 2024-09-07 13:52:11

创建背景的方式与创建信号或前景的方式相同:使用将值应用于每个像素的函数。然后将前景添加到背景中就完成了。

函数 NDGRID 可能对您有用。

例如,你可以写:

%# create x and y coordinates for every pixel in the image
[xx,yy] = ndgrid(1:10,1:10);

%# create foreground
foreground = xx.^2 + yy.^2;

%# create an angled background, where y = -10*x;
background = -xx*10;

%# show all
figure
subplot(1,3,1),imshow(foreground,[])
subplot(1,3,2),imshow(background,[])
subplot(1,3,3),imshow(foreground+background,[])

You create a background the same way you create the signal, or foreground: using a function that applies a value to every pixel. Then you add foreground to background and you're done.

The function NDGRID is likely to be useful for you.

For example, you can write:

%# create x and y coordinates for every pixel in the image
[xx,yy] = ndgrid(1:10,1:10);

%# create foreground
foreground = xx.^2 + yy.^2;

%# create an angled background, where y = -10*x;
background = -xx*10;

%# show all
figure
subplot(1,3,1),imshow(foreground,[])
subplot(1,3,2),imshow(background,[])
subplot(1,3,3),imshow(foreground+background,[])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文