views:

34

answers:

1

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.

+1  A: 

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,[])
Jonas