Resolution of a plotted function

2 次查看(过去 30 天)
simira atraqi
simira atraqi 2012-4-17
回答: Rishi 2023-12-30
Hello Everyone,
I need to put this function (f) in a matrix to print it as a figure, but how can I put it in the same matrix (4001, 3001) with two resolutions (1um, 2um) and the same wavelength 100um?
May someone please help me in solving this query.
Thanks
f = @(x) 3*sin(x*2*pi/wavelength) + 1003;
% The function for the sine wave with the
% amplitude 3 µm and wave length of about 100 µm.
%Mean level is 1003 µm.

回答(1 个)

Rishi
Rishi 2023-12-30
Hello Simira,
I undersrand that you want to know how to use same function 'f' with two different resolutions in a matrix of same size.
Here is the code to do the same, assuming that the matrix dimensions refer to the number of data points:
wavelength = 100;
matrix_size_x = 4001; % number of points in the x-dimension
matrix_size_y = 3001; % number of points in the y-dimension
f = @(x) 3*sin(x*2*pi/wavelength) + 1003;
[x_1um, y_1um] = meshgrid(0:1:(matrix_size_x-1), 0:1:(matrix_size_y-1));
matrix_1um = f(x_1um);
[x_2um, y_2um] = meshgrid(0:2:(2*matrix_size_x-2), 0:2:(2*matrix_size_y-2));
matrix_2um = f(x_2um);
figure;
imagesc(matrix_1um);
colorbar;
title('Function f at 1um resolution');
figure;
imagesc(matrix_2um);
colorbar;
title('Function f at 2um resolution');
To learn about 'meshgrid' function, you can refer to the following documentation:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Volume Visualization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by