MATLAB: Hi. I have a text file containing two columns of numeric data with millions of rows. A small amount of data is given below. I need to plot the graph from one “Layer” to another”Layer” in a single graph. Kindly help

multiple layer graphs

This is a force data for one of my projects. A x-y graph is needed to understand if there is any spike in the data.

Best Answer

fid = fopen('New Text Document.txt') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
idx = contains(S,'Layer') ;
idx = find(idx) ;
figure
hold on
for i = 1:length(idx)-1
L = S(idx(i)+1:idx(i+1)-1) ;
if ~isempty(L)
L = cell2mat(cellfun(@str2num,L,'un',0)) ;
plot(L(:,1),L(:,2),'color',rand(1,3))
end
end