does anyone have the "leap frog" algorithm matlab script?plz help i need it!
25 次查看(过去 30 天)
显示 更早的评论
leap frog matlab script or matlab code is what i need
0 个评论
回答(3 个)
Walter Roberson
2013-12-14
Google can find SFLA MATLAB code. I have no idea of the quality of it, and I have no idea whether it is legitimate code or will delete everything on your hard disk.
I would keep in mind that if you are doing an assignment or project, that you cannot copy someone else's code.
4 个评论
Walter Roberson
2014-2-1
You could try asking the authors of one of the following papers. Chances are, though, that it would be faster for you to implement it yourself.
T S Singh
2016-5-5
编辑:T S Singh
2016-5-5
You can try the following code. Its an application of Leap Frog Algorithm applied to Simple harmonic Motion
close all
clear all
clc
x(1) = 0.0; % initial position
v(1) = 2.0; % initial velocity
del_t = 0.2; % time increment
k = 0.1; % spring constant
m = 1.0; % mass
Tf = 100.0; % Final time
t = 0:del_t:Tf;
N = length(t);
v_hlf(1)=v(1)+(0.5*del_t*(-k/m)*x(1));
for j=2:N
x(j)=x(j-1)+v_hlf(j-1)*del_t;
v(j)=v_hlf(j-1)+0.5*(del_t*(-k/m)*x(j));
v_hlf(j)=v(j-1)+0.5*(del_t*(-k/m)*x(j));
end
figure; plot(t, x);
grid on;
0 个评论
João Socorro Pinheiro Ferreira João Ferreira
2021-11-24
resolver:
O arquivo-m advection\_LW\_pbc.m implementa o método Lax-Wendroff para a equação advecção em $0 \leq x \leq 1$ com condições de contorno periódicas.
\begin{itemize}
\item [(a)] Modifique o arquivo.m para criar uma versão advection\_lf\_pbc.m implementando o leapfrog e verifique se isso é preciso de segunda ordem. Observe que você terá que especificar dois níveis de dados iniciais. Para o conjunto de teste de convergência $U_j^1 = u (x_j, k)$, a solução verdadeira em tempo $k$.
\item [(b)] Modifique advection\_lf\_pbc.m para que os dados iniciais consistam em um pacote de ondas
\begin{equation}
\eta (x) = \exp{(-\beta (x - 0.5)^2}\sin{(\xi x)} \hspace{1.5cm} (Ex. 10.9a)
\label{011121b}
\end{equation}
Descubra a verdadeira solução $u (x, t)$ para esses dados. Usando $\beta = 100$, $\xi = 80$ e $U_j^1 = u (x, k)$, teste se seu código ainda exibe uma precisão de segunda ordem para $k$ e $h$ suficientemente pequena.
\item [(c)] Usando $\beta = 100$, $\xi = 150$ e $U_j^1 = u (x_j, k)$, estime a velocidade do grupo do pacote de onda
calculado com leapfrog usando $m = 199$ e $k = 0.4h$. Quão bem isso se compara com o valor (10.52) predito pela equação modificada?
\end{itemize}
1 个评论
Steven Lord
2021-11-24
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!