I have new questions after meeting the criteria from these Matlab plot graph(segment by segment) and user input threshold value before writing to txt and Matlab load entire file but show and plot segment by segment
I was tasked to plot the graph and show the peak nodes (those that is > threshold) but only manage to plot the nodes and it is stuck here:

I'm trying to plot it out what this pic shows but I'm having difficulty:

Here's my code:
for e = 1:size(rows,1),
%plot normal graph first, hold it before plotting nodes
%so that it is combined
figure,plot(rows(e,:)), hold on;
%put the 'INPUT' statement outside the loop, or it will be evaluated
%multiple times (every time all the other conditions are true)
threshold = input('Key in the threshold value to use: ');
% loop over this if statement to find peaks in this row
for k = 2 : 999
if (rows(e,k) > rows(e, k-1) && rows(e,k) > rows(e,k+1) && rows(e,k) > threshold)
beat_count = beat_count + 1;
peaks(beat_count)=rows(e,k);
peak_x(beat_count) = k + 1000 * (e - 1);
plot(rows(e,peak_x(beat_count)),'ro');
end
end
%pop up text to plot new segment
fprintf(1, 'press any key to continue!\n');
% pause, on keypress go to next plot
pause;
end
% since peaks array keeps growing, we should print it out all at once:
fprintf(fid, 'the following peaks were found:\n');
for ii = 1:beat_count
fprintf(fid, 'x = %d; peak = %f\n ', peak_x(ii), peaks(ii)); %open writer
end
fclose(fid); % close the file once you're done
I have 3 questions actually but I want to solve it 1 by 1. So the first 1 will be
Plot the graph and show the peak nodes
'O'to those that is > than the threshold input by user (I manage to plot the peak'O'but it's all stuck at 1 place)As the graph is being segment into every
1000, is it possible to increase the value on the x-axis? Like the first plot is from0to1000and the second will be1001to2000and so forth untill the entire length of the data.Allow user input from whichever segment they want to start, for example I can key in a value so I will plot from
3001to4000and each time after I key in a threshold value it will write the output to text file instead of writing all the output to the textfile all at the end. (If anything error occur halfway, you need to redo everything so this is to prevent from repeating the entire process if something happen halfway and I can start from where I stop, too)