楼主: tulipsliu
4685 88

[学习分享] 一个MATLAB 的程序学习 [推广有奖]

经济学论述自由撰稿人!

已卖:2751份资源

学科带头人

45%

还不是VIP/贵宾

-

威望
0
论坛币
386043 个
通用积分
526.9898
学术水平
127 点
热心指数
140 点
信用等级
103 点
经验
46986 点
帖子
1773
精华
0
在线时间
2509 小时
注册时间
2007-11-5
最后登录
2024-8-16

初级热心勋章

楼主
tulipsliu 在职认证  发表于 2020-11-9 19:16:53 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
作者: Tulipsliu
本文采用普通帖子模式,而不是使用Markdown 格式发帖,测试是否可以加入数学公式;




一、数学公式 Introduction

This example shows how Global Optimization Toolbox functions,
particularly |GlobalSearch| and |MultiStart|, can help locate the maximum
of an electromagnetic interference pattern. For simplicity of modeling,
the pattern arises from monochromatic polarized light spreading out from
point sources.

$$E_i = \frac{A_i}{d_i(x)} \sin(\phi_i + \omega (t - d_i(x)/c) ),$$ where $\phi_i$ is the phase at time zero for source $i$, $c$ is the speed
of light, $\omega$ is the frequency of the light, $A_i$ is the amplitude
of source $i$, and $d_i(x)$ is the distance from source $i$ to $x$.
For a fixed point $x$ the intensity of the light is the time average of
the square of the net electric field. The net electric field is sum of
the electric fields due to all sources. The time average depends only on
the sizes and relative phases of the electric fields at $x$. To calculate
the net electric field, add up the individual contributions using the
phasor method. For phasors, each source contributes a vector. The length
of the vector is the amplitude divided by distance from the source, and
the angle of the vector, $\phi_i - \omega d_i(x)/c$ is the phase at the
point.

For this example, we define three point sources with the same frequency
($\omega$) and amplitude ($A$), but varied initial phase ($\phi_i$). We
arrange these sources on a fixed plane.



  1. % Frequency is proportional to the number of peaks
  2. relFreqConst = 2*pi*2.5;
  3. amp = 2.2;
  4. phase = -[0; 0.54; 2.07];

  5. numSources = 3;
  6. height = 3;

  7. % All point sources are aligned at [x_i,y_i,z]
  8. xcoords = [2.4112
  9.            0.2064
  10.            1.6787];
  11. ycoords = [0.3957
  12.            0.3927
  13.            0.9877];
  14. zcoords = height*ones(numSources,1);         

  15. origins = [xcoords ycoords zcoords];
复制代码
Posing the Optimization Problem
We are interested in the location where this wave intensity reaches
its highest peak.
The wave intensity ($I$) falls off as we move away from the source
proportional to $1/d_i(x)$. Therefore, let's restrict the space of
viable solutions by adding constraints to the problem.
Now our problem has become:
$$ \max_{x,y} I(x,y) $$
subject to
$$ (x - x_{c1})^2 + (y - y_{c1})^2 \le r_1^2 $$
$$ (x - x_{c2})^2 + (y - y_{c2})^2 \le r_2^2 $$
$$ (x - x_{c3})^2 + (y - y_{c3})^2 \le r_3^2 $$
$$-0.5 \leq x \leq 3.5$$
$$-2 \leq y \leq 3$$


where $(x_{cn},y_{cn})$ and $r_n$ are the coordinates and aperture radius
of the $n^{th}$ point source, respectively. Each source is given an
aperture with radius 3. The given bounds encompass the feasible region.
The objective ($I(x,y)$) and nonlinear constraint functions are defined
in separate MATLAB(R) files, |waveIntensity.m| and |apertureConstraint.m|,
respectively, which are listed at the end of this example.

  1. % Visualize the contours of our interference surface
  2. domain = [-3 5.5 -4 5];
  3. figure;
  4. ezcontour(@(X,Y) arrayfun(@(x,y) waveIntensity_x([x y]),X,Y),domain,150);
  5. hold on

  6. % Plot constraints
  7. g1 = @(x,y)  (x-xcoords(1)).^2 + (y-ycoords(1)).^2 - 9;
  8. g2 = @(x,y)  (x-xcoords(2)).^2 + (y-ycoords(2)).^2 - 9;
  9. g3 = @(x,y)  (x-xcoords(3)).^2 + (y-ycoords(3)).^2 - 9;
  10. h1 = ezplot(g1,domain);
  11. h1.Color = [0.8 0.7 0.1]; % yellow
  12. h1.LineWidth = 1.5;
  13. h2 = ezplot(g2,domain);
  14. h2.Color = [0.3 0.7 0.5]; % green
  15. h2.LineWidth = 1.5;
  16. h3 = ezplot(g3,domain);
  17. h3.Color = [0.4 0.4 0.6]; % blue
  18. h3.LineWidth = 1.5;

  19. % Plot bounds
  20. lb = [-0.5 -2];
  21. ub = [3.5 3];
  22. line([lb(1) lb(1)],[lb(2) ub(2)],'LineStyle','--')
  23. line([ub(1) ub(1)],[lb(2) ub(2)],'LineStyle','--')
  24. line([lb(1) ub(1)],[lb(2) lb(2)],'LineStyle','--')
  25. line([lb(1) ub(1)],[ub(2) ub(2)],'LineStyle','--')
  26. title('Pattern Contours with Constraint Boundaries')
复制代码


结束语:
我也是在不断的测试,希望在明年有较好的教学课程发布论坛。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB matla atlab 程序学习 Lab

劳动经济学

沙发
tulipsliu 在职认证  发表于 2020-11-25 19:29:39
$$
\widehat{\beta} = \left((Z_t^\top \otimes I_K)W_T(Z_t \otimes I_K)\right)^{-1}(Z_t^\top \otimes I_K)W_Ty,
$$

藤椅
tulipsliu 在职认证  发表于 2020-11-25 19:30:05
$$
W_T =
\begin{bmatrix}
\Omega^{-1}_1 & \cdots & 0 \\
\vdots & \ddots & \vdots \\
0 & \cdots & \Omega^{-1}_T
\end{bmatrix}.
$$

板凳
tulipsliu 在职认证  发表于 2020-11-25 19:30:41
$$
\mathbb{E}(u_tu_t^\top) = \Omega_t = \left(1 - G(s_t)\right)\Sigma_1 + G(s_t)\Sigma_2,\quad t=1,\ldots,T.
$$

报纸
tulipsliu 在职认证  发表于 2020-11-25 19:31:06
$$
\begin{align*}
\widehat{\beta} &= \mbox{vec}[\widehat{\mu}, \widehat{A}_1, ..., \widehat{A}_p] \\
                 &= \left[\sum^{T_{sb}-1}_{t=1}\left(Z_t Z_t^\top \otimes (\widetilde{B}\widetilde{B}^\top)^{-1}\right) + \sum^{T}_{t=T_{sb}}\left(Z_t Z_t^\top \otimes (\widetilde{B}\widetilde{\Lambda}\widetilde{B}^\top)^{-1}\right) \right]^{-1} \\
                 &\quad \times \left[\sum^{T_{sb}-1}_{t=1}\left(Z_t \otimes (\widetilde{B}\widetilde{B}^\top)^{-1}\right)y_t + \sum^{T}_{t=T_{sb}}\left(Z_t \otimes (\widetilde{B}\widetilde{\Lambda}\widetilde{B}^\top)^{-1}\right)y_t \right],
\end{align*}
$$

地板
tulipsliu 在职认证  发表于 2020-11-25 19:31:29
$$
\widehat{\Sigma}_1 = \frac{1}{T_{sb} - 1} \sum _{t = 1}^{T_{sb} -1}\widehat{u}_t\widehat{u}_t^\top \qquad \text{and} \qquad \widehat{\Sigma}_2 = \frac{1}{T - T_{sb} + 1} \sum _{t = T_{sb}}^{T}\widehat{u}_t\widehat{u}_t^\top.
$$

7
tulipsliu 在职认证  发表于 2020-11-25 19:32:16
$$
Q(\theta) =
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos(\theta_1) & -\sin(\theta_1) \\
0 & \sin(\theta_1) & \cos(\theta_1)
\end{bmatrix}
\times
\begin{bmatrix}
\cos(\theta_2) & 0 & -\sin(\theta_2) \\
0 & 1 & 0 \\
\sin(\theta_2) & 0 & \cos(\theta_2)
\end{bmatrix}
\times
\begin{bmatrix}
\cos(\theta_3) & -\sin(\theta_3) & 0 \\
\sin(\theta_3) & \cos(\theta_3) & 0 \\
0 & 0 & 1
\end{bmatrix},
$$

8
tulipsliu 在职认证  发表于 2020-11-25 19:32:56
$$
\log \mathcal{L}(\delta) = \log \mathcal{L}(\widehat{\beta}, \delta) = T^{-1}\sum^T_{t =1} l_t(\widehat{\beta}, \delta),
$$

9
tulipsliu 在职认证  发表于 2020-11-25 19:33:25
$$
\log \mathcal{L}(\beta) = \log \mathcal{L}(\beta, \widetilde{\delta}) = T^{-1}\sum^T_{t =1} l_t(\beta, \widetilde{\delta})
$$

10
tulipsliu 在职认证  发表于 2020-11-25 19:34:26
\begin{aligned} \left.\begin{aligned}        B'&=-\partial \times E,\\         %加&指定对齐位置        E'&=\partial \times B - 4\pi j,       \end{aligned} \right\}                                                                %加右} \qquad \text{Maxwell's equations}\end{aligned}

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-6 08:23