Error function optimisation method to calculate the velocity of a travelling wave

1 回表示 (過去 30 日間)
UserCJ
UserCJ 2023 年 9 月 10 日
編集済み: Torsten 2023 年 9 月 11 日
Hi everyone, I'm trying to use an error optimisation method using interpolation and least quare method for a travelling wave solution. I have a mat file (SS) of size 10000*200 where time steps are defined by rows and node number is defined by columns. In this simulation, there are 10000 timesteps and 200 nodes. These values provide a travelling wave solution as follows.
To calculate the velocity of these waves, I'm trying to use the error optimisation method as given in the pseudo code below.
I tried coding that as follows, however, i'm having a trouble understanding and defining "c" in the anonymous function in the code.
v_t= zeros(Tmax-1);
sol_current = SS(1,:);
%x1= 1:Tmax/200:Tmax;
xq = linspace(0,1,200);
for n=1:length(Tmax)
sol_future = SS(n+1,:);
fun=@(c)...
end
It would be great if anyone can help me to code this method. Thank you!

回答 (1 件)

Torsten
Torsten 2023 年 9 月 10 日
編集済み: Torsten 2023 年 9 月 10 日
For each of the 200 times, extract the node number where your solution equals 0.5. Plot node number as a function of time. The slope of this (in your case most probably linear) curve gives the wave speed.
  7 件のコメント
Torsten
Torsten 2023 年 9 月 11 日
編集済み: Torsten 2023 年 9 月 11 日
In order to apply "interp1", the vector vec must be strictly monotonic. I hope that restricting the interpolation to values > 0.2 and < 0.8 will be successful to achieve this. Otherwise you have to include your data or experiment for yourself.
I assume N = 0:199, am I right ?
pos = zeros(10000,1);
for it = 1:10000
vec = SS(it,:);
idx = vec > 0.2 & vec < 0.8;
pos(it) = interp1(vec(idx),N(idx),0.5);
end
plot(t,pos)
Star Strider
Star Strider 2023 年 9 月 11 日
In my approach to this problem (Answer, and a subsequent Comment with a slightly different implementation), I define a narrow range of indices to interpolate over (‘idxrng’ in that code) in each iteration of the loop. That usually works to eliminate the non-unique values problem, although I do not have the actual data mentioned here to experiment with.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by