matlab薄透镜对物体成像
基于MATLAB的薄透镜对物体成像、薄透镜对高斯光束的作用以及薄透镜的物像距计算的仿真。
1. 薄透镜对物体成像
% 薄透镜对物体成像
function lens_imaging()% 参数设置f = 10; % 透镜焦距s = 20; % 物距s_prime = f * s / (s - f); % 像距magnification = -s_prime / s; % 放大率% 绘制物体和像figure;hold on;plot([-s, -s], [-1, 1], 'b', 'LineWidth', 2); % 物体plot([s_prime, s_prime], [-magnification, magnification], 'r', 'LineWidth', 2); % 像plot([0, 0], [-1, 1], 'k--', 'LineWidth', 1); % 透镜位置plot([0, -s], [0, 0], 'k', 'LineWidth', 1); % 光轴plot([0, s_prime], [0, 0], 'k', 'LineWidth', 1); % 光轴legend('物体', '像', '透镜', '光轴');title('薄透镜对物体成像');xlabel('距离');ylabel('高度');hold off;
end
2. 薄透镜对高斯光束的作用
% 薄透镜对高斯光束的作用
function lens_gaussian_beam()% 参数设置f = 10; % 透镜焦距zR = 2; % 输入光束的瑞利距离s = 15; % 物距s_prime = f * s / (s - f); % 像距zR_prime = zR * (s_prime / s)^2; % 输出光束的瑞利距离% 绘制高斯光束figure;hold on;theta = linspace(0, 2*pi, 100);r = sqrt(zR^2 + (s - f)^2);x = r * cos(theta) + s;y = r * sin(theta);plot(x, y, 'b', 'LineWidth', 2); % 输入光束r_prime = sqrt(zR_prime^2 + (s_prime - f)^2);x_prime = r_prime * cos(theta) + s_prime;y_prime = r_prime * sin(theta);plot(x_prime, y_prime, 'r', 'LineWidth', 2); % 输出光束plot([0, 0], [-5, 5], 'k--', 'LineWidth', 1); % 透镜位置plot([0, s], [0, 0], 'k', 'LineWidth', 1); % 光轴plot([0, s_prime], [0, 0], 'k', 'LineWidth', 1); % 光轴legend('输入光束', '输出光束', '透镜', '光轴');title('薄透镜对高斯光束的作用');xlabel('距离');ylabel('高度');hold off;
end
3. 薄透镜的物像距计算
% 薄透镜的物像距计算
function lens_distance_calculation()% 参数设置f = 10; % 透镜焦距s = 15; % 物距s_prime = f * s / (s - f); % 像距% 输出结果fprintf('物距 s = %.2f\n', s);fprintf('像距 s_prime = %.2f\n', s_prime);
end
主程序
% 主程序
clc;
clear;% 薄透镜对物体成像
lens_imaging();% 薄透镜对高斯光束的作用
lens_gaussian_beam();% 薄透镜的物像距计算
lens_distance_calculation();
参考代码 薄透镜对物体成像 www.youwenfan.com/contentcsf/78344.html
说明
- 薄透镜对物体成像:根据薄透镜公式计算像距和放大率,并绘制物体和像的位置。
- 薄透镜对高斯光束的作用:根据改进的薄透镜公式计算输出光束的瑞利距离,并绘制输入和输出光束的位置。
- 薄透镜的物像距计算:根据薄透镜公式计算物距和像距。