- <content type="html"><![CDATA[<h1>自再现模的迭代法的Matlab代码</h1><p>垂雷大学激光工程的作业,网上找了一下<a href="https://wenku.baidu.com/view/994ceae9f8c75fbfc77db25d.html">百度文库有篇相关的文章</a>,不过里面的代码写的不太规范(命名啊,空格啊),就按照自己的习惯改了改,再说百度文库也不好复制粘贴,就放在这里吧。万一有人用得着呢?</p><p>(一个课程的同学别抄啊)</p><pre><code>% 注:QU渡越函数在提交的同一目录下,缺少这个函数无法运行clearclcglobal steps cavity_length waveloss mirror_long wavalength% 定义各种参数的初始值wavalength = 0.0000006328; %波长cavity_length = 0.00006328; %腔长mirror_long = 0.00001582; %镜长N = 300; %渡越次数waveloss = 2*pi/wavalength; %波失steps = 500; %步长% 声明变量的空间x = linspace(-mirror_long, mirror_long, steps);uN = ones(1,steps);u1 = ones(1,steps);u_n = ones(1,steps);% 经过1次渡越for i = 1:steps u1(i) = QU(x(i),u_n);endu_n1 = u1/max(abs(u1));% 经过N次渡越for i = 1:Nfor j = 1:stepsuN(j) = QU(x(j),u_n);endu_n= uN/max(abs(uN));end% 做图,振幅subplot(2,1,1)grid onplot(x,abs(uN)/abs(uN(steps/2)), 'b--')hold onplot(x,abs(u1)/abs(u1(steps/2)),'r')title('振幅');xlabel('振幅分布');ylabel('相对振幅');angle_uN=angle(uN)/pi*180;angle_u1=angle(u1)/pi*180;angle_uN=angle_uN-angle_uN(steps/2);angle_u1=angle_u1-angle_u1(steps/2);%做图,相位subplot(2,1,2)grid onplot(x,angle_uN, 'b--')hold onplot(x,angle_u1, 'r')title('相位');xlabel('相位分布');ylabel('相对相位');</code></pre><p>QU 函数的代码(文件名为QU.m ,跟上面的代码放在一起就好)</p><pre><code>function y=QU(x,u)global steps cavity_length waveloss mirror_long wavalengthx_=linspace(-mirror_long,mirror_long,steps);step_length=2*mirror_long/(steps-1);y=sqrt(1i/cavity_length/wavalength*exp(-1i*waveloss*cavity_length))*sum(exp(-1i*waveloss/2/cavity_length*(-x_+x).^2).*u)*step_length;</code></pre><pre><code> ```yml _config.yml highlight: enable: true line_number: true auto_detect: false tab_replace: markdown: render: html: true xhtmlOut: false breaks: false linkify: true typographer: true quotes: '“”‘’' plugins: - markdown-it-abbr - markdown-it-footnote - markdown-it-ins - markdown-it-sub - markdown-it-sup - markdown-it-deflist anchors: level: 1 collisionSuffix: 'v' permalink: false permalinkClass: header-anchor permalinkSymbol: "" permalinkBefore: false date_format: ll archive_generator: per_page: 0 yearly: true monthly: false daily: false theme: cutie ```</code></pre><p>结果大概长这样~</p><p><img src="https://i.loli.net/2021/10/05/4mP3CAgilEQ9b2y.jpg" alt="结果.jpg"></p><p>$$\begin{align*}y = y(x,t) &= A e^{i\theta} \&= A (\cos \theta + i \sin \theta) \&= A (\cos(kx - \omega t) + i \sin(kx - \omega t)) \&= A\cos(kx - \omega t) + i A\sin(kx - \omega t) \&= A\cos \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) + i A\sin \Big(\frac{2\pi}{\lambda}x - \frac{2\pi v}{\lambda} t \Big) \&= A\cos \frac{2\pi}{\lambda} (x - v t) + i A\sin \frac{2\pi}{\lambda} (x - v t)\end{align*}$$</p>]]></content>
0 commit comments