Note that there are some explanatory texts on larger screens.

plurals
  1. POMatlab plot graph(segment by segment) and user input threshold value before writing to txt
    primarykey
    data
    text
    <p>I have been trying to write the x-axis values (peak only) to txt file using this code (this method is working).</p> <pre><code>%determine the bpm %count the dominant peaks in the signal fid = fopen('y1.txt','a'); %txt naming and append beat_count = 0; for k = 2 : length(pbcg)-1 if (pbcg(k) &gt; pbcg(k-1) &amp;&amp; pbcg(k) &gt; pbcg(k+1) &amp;&amp; pbcg(k) &gt; 1) beat_count = beat_count + 1; end end fprintf(fid, '%i\n', k); %open writer fs = 100; %freq 100hz N = length(pbcg); duration_in_seconds = N/fs; duration_in_minutes = duration_in_seconds/60; BPM_avg = beat_count/duration_in_minutes; fclose(fid); %close writer </code></pre> <p>But the problem comes in here when i have modified it to plot the graph segment by segment (i manage to get this done) but the problem is not able to write the x-axis value to the txt file when my code is like this.. anything i done wrong?</p> <pre><code>%plot segment by segment data = pbcg;%data value from 1 to 10000 rows = reshape(data, 1000, numel(data)/1000)';%reshape the data into %matrix by 1000 against total num of element in array and then / 1000) fid = fopen('y1.txt','a'); %txt naming and append beat_count = 0; for e = 1:size(rows,1), %plot normal &amp; with nodes together figure,plot(rows(e,:)),hold on,plot(rows(e,:),'ro'); %if statement to find peak if (pbcg(k) &gt; pbcg(k-1) &amp;&amp; pbcg(k) &gt; pbcg(k+1) &amp;&amp; pbcg(k)&gt; input('Key in the threshold value: ')) beat_count = beat_count + 1; peaks(beat_count)=pbcg(k); end pause;%pause, on keypress go to next plot fprintf(fid, 'x_axis%i\n ', peaks); %open writer end fclose(fid); %close writer </code></pre> <p>the result i got was the entire list of peaks even after i enter the threshold value.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload