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

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

Torsten
Torsten il 10 Set 2023
Modificato: Torsten il 10 Set 2023
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 Commenti
Torsten
Torsten il 11 Set 2023
Modificato: Torsten il 11 Set 2023
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 il 11 Set 2023
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.

Accedi per commentare.

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by