How to perform calc. on the selected part of curve and then reassemble it with rest part of curve in MATLAB?

Hello everyone,
I would be thankful if someone can help me to guide me here. Here is the attached plot between VP and Depth. I want to perform some calculations only on the encircled part of VP curve (i.e from Depth 1917 - 1976 meter) and want to plot (new) full curve after calculations in such a way that the the encircled part is changed but rest of curve is same (above and below).
Plz help me to solve this issue. If I select encircled part and perform some calculations then how can I reassembled the circled part with above and below portions.
Thanks

 Accepted Answer

hello
see my little demo below
I extracted the portion of data of interest - you can do computation or smoothing and put back the smoothed portion in lieu of the original data
my plot is horizontal but that does not impact the demo principle
code
% dummy data
depth = (1870:2200);
VP = 1+rand(size(depth));
VP(1917-1870:1976-1870) = VP(1917-1870:1976-1870) + 2; % create a local step
%% main code
ind = find(depth>=1917 & depth<=1976);
VP_extract = VP(ind);
% math
VP_extract_mean = mean(VP_extract);
% smooth
VP_extract_smooth = smoothdata(VP_extract,'gaussian',20);
% replace original VP_extract with VP_extract_smooth
newVP = VP;
newVP(ind) = VP_extract_smooth;
plot(depth,VP,depth,newVP);

8 Comments

@Mathieu NOE Thank fo your reply. The code works but in that case, if I want to extract data or want to save full VP curve with new computed part. How can I save a matrix array?
hello Nisar
so the extracted part is the array VP_extract
the full (new) VP is newVP
you can save both of them in a cell array if you want (they don't have the same length)
@Mathieu NOE Can you plz help to solve this small issue,
I am trying this way and following figure appears
newVP = vp;
newVP(ind) = VP_FSM2;
figure(2), stairs(vp,TWT3); hold on; stairs(newVP,TWT3); set(gca, 'ydir', 'reverse');
The original curve is blue while modified is orange curve. What I want is blue should appear full curve as it is original and orange should appear in small part as modified.
hello Nisar
happy new year !
see my little demo below
% dummy data
depth = (1870:2000);
VP = 1+rand(size(depth));
VP(1917-1870:1976-1870) = VP(1917-1870:1976-1870) + 2; % create a local step
%% main code
ind = find(depth>=1917 & depth<=1976);
VP_extract = VP(ind);
% smooth
VP_extract_smooth = smoothdata(VP_extract,'gaussian',20);
newVP = VP_extract_smooth;
newdepth = depth(ind);
figure(2), stairs(VP,depth,'linewidth',2);
hold on;
stairs(newVP,newdepth,'linewidth',3);
set(gca, 'ydir', 'reverse');

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!