How to reshape a curve?
5 views (last 30 days)
Show older comments
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
Accepted Answer
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)]);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!