How to reshape a curve?

5 views (last 30 days)
Joe Liang
Joe Liang on 27 Mar 2014
Commented: Joe Liang on 31 Mar 2014
Hello, Masters:
I have a shock wave emission curve in water like this:
x is the distance from shock wave center and y is the shock wave pressure. The calculation was done by the Kirkwood-Bethe method.
However, this curve is physically "unreasonable" because liquid does not allow a broken wave.What we normally do is use a vertical guide line (as red line in figure) to let the left region equals the right region (as shown in the green line). After reshaping the wavefront, it should like this:
For less than 10 figures, we normally do it manually. However, we have now hundreds of these figures, and thus need a nice matlab algorithm to handle it.
Anyone has met this kind problem before? Would you please provide any idea to solve this problem...
Thank you!!!
Joe
p.s. the data is attached.
  3 Comments
Joe Liang
Joe Liang on 28 Mar 2014
Hi, José-Luis:
You are right. Where to place the vertical line to make the left and right areas equal.
Regards,
Joe
Andrei Bobrov
Andrei Bobrov on 28 Mar 2014
Where all data?

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 31 Mar 2014
load data
[~,iymax] = max(y);
yx = griddedInterpolant(y(end:-1:iymax),x(end:-1:iymax),'pchip');
y0 = fminsearch(@(x)yx(x),y(end));
x0 = yx(y0);
jj = find(x(1:iymax)<x0,1,'last');
f1 = griddedInterpolant(x(jj:iymax),y(jj:iymax),'pchip');
xx = x(iymax:end);
yy = y(iymax:end);
t0 = yy > y0;
t00 = x0 < xx;
t1 = t0 & t00;
f2 = griddedInterpolant([x0;flipud(xx(t1))],[y0;flipud(yy(t1))],'pchip');
t2 = ~t0 & t00;
f3 = griddedInterpolant([x0;xx(t2)],[y0;yy(t2)],'pchip');
xout = fzero(@(X)integral2(@(x,y)ones(size(x)),X,x(iymax),@(x)f2(x),@(x)f1(x))...
- integral2(@(x,y)ones(size(x)),x0,X,@(x)f3(x),@(x)f2(x)),[x0,x(iymax)]);
  1 Comment
Joe Liang
Joe Liang on 31 Mar 2014
Dear Andrei Bobrov:
Thank you very very much for your reply! It works!
It's really a genius idea to segment lines in such a elegant way!Especially the use of function "griddedInterpolant". Great!
Regards,
Joe
One small questions on your last line of code.You use integral2 to integrate an area. Here you used @(x,y)ones(size(x)). Is it similar to use @(x,y)1 or the latter is not allowed in Matlab?

Sign in to comment.

More Answers (0)

Categories

Find more on Physics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!