Sampling a function.

23 次查看(过去 30 天)
Vinay Prakash
Vinay Prakash 2020-10-12
Hello everyone, I am working on the following problem statement:
"Consider the analytic function ( 1 + cos 2 π ( f_1 x + f_2 y ) ), where f 1 , f 2 are a spatial frequencies with units of m-1, and x , y are spatial variables with units of m. This function is to be sampled with a 2-D ideal sampling function. Pick the frequencies with the condition that f 1 ≠ f 2, and then compute and display as an image the ideally spaced samples in a square array that is at least 10 periods on a side for the lower frequency. Then, compute and display the samples for a sampling function which undersamples in both dimensions. "
So far I have only been able to plot a contour and a 3D plot for this function by writing the following code below. I am utterly lost at how to sample this function by a ' 2D ideal sampling function'. Any help is much appreciated.
clc;
close all;
clear all;
f_1=100;
f_2=200;
%f_1 = input('Enter first frequency: ');
%f_2 = input('Enter second frequency (not equal to first frequency!): ');
zfun = @(x,y) 1+cos(2*pi*(f_1*x + f_2*y));
zhandle = fcontour(zfun)
[x,y] = meshgrid(-10:.2:10);
%f = 1+cos(2*pi*(f_1*x + f_2*y));
surf(x,y,1+cos(2*3.14*(f_1*x + f_2*y)))
  3 个评论
Image Analyst
Image Analyst 2020-10-12
Perhaps "display as an image" means that you use imshow(), image(), or imagesc() instead of surf() which does a topographical/perspective rendering.
Vinay Prakash
Vinay Prakash 2020-10-12
Thank you for that advice @ImageAnalyst. I will try using these commands to display the function.
Can you guide towards how to go about sampling the function?

请先登录,再进行评论。

回答(0 个)

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by