Sampling a function.

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 Comments

Perhaps "display as an image" means that you use imshow(), image(), or imagesc() instead of surf() which does a topographical/perspective rendering.
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?

Sign in to comment.

Answers (0)

Products

Asked:

on 12 Oct 2020

Commented:

on 12 Oct 2020

Community Treasure Hunt

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

Start Hunting!