# I have a text file with time "T2-distribution" and Amplitude at each depth.X-axis are my values adjacent to 'T2' row only. I want area under curve between T2 and amplitude at the respective 'DEPTH' (ignore values adjacent to 'DEPTH'- only in row 4)?

1 view (last 30 days)
KRISHNA NISHCAL BHARATULA on 17 Mar 2017
Hole: 123A
Top: 78.67
T2 3.34 4.26 8.16 9.84 10.01
DEPTH 0 1 2 3 4
78.67 3.38 9.28 7.86 0.00 0.00
80.52 4.68 9.27 0.00 0.00 1.24
91.50 6.66 2.34 1.23 0.00 0.00
95.67 7.88 6.88 5.43 0.00 2.34
100.01 5.44 6.54 8.23 5.01 0.00
##### 2 CommentsShow NoneHide None
KSSV on 17 Mar 2017
KRISHNA NISHCAL BHARATULA on 17 Mar 2017
yes it is. But I need to find the area under each of those curves which gives 'porosity of rock' at a particular depth. I appreciate your quick response, thank you very much.
:)

KSSV on 17 Mar 2017
fid = fopen('your txt file') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
%%Get positions
idx1 = find(not(cellfun('isempty',strfind(S, 'T2')))); % T2 position
idx2 = find(not(cellfun('isempty',strfind(S, 'DEPTH')))); % T2 position
idx3 = idx2:length(S) ;
%%Get the required
x = cell2mat(cellfun(@str2num,strsplit(S{idx1}),'un',0)) ;
depth = cell2mat(cellfun(@str2num,strsplit(S{idx2}),'un',0)) ;
data = cell2mat(cellfun(@str2num,S(idx3),'un',0)) ;
y = data(:,1) ;
data = data(:,2:end) ;
%%each area
N = length(depth) ;
Area = zeros(N,1) ;
for i = 1:N
Area(i) = trapz(x,data(i,:)) ;
end
##### 2 CommentsShow NoneHide None
KRISHNA NISHCAL BHARATULA on 17 Mar 2017
I am getting this error. need help on this. "Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier."
KRISHNA NISHCAL BHARATULA on 17 Mar 2017
Thank you very much it worked!!!...amazing! :D

### Categories

Find more on Low-Level File I/O 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!