How to return results for all 10 detectors at the same time?
Show older comments
This is my code that I have been using in order to find and plot the Right Hand peak of the data provided. There are 10 numbers of detectors, and that is known by dnum. At the moment, I have to manually assign a number on dnum (See USER INPUTS) and hit run on each detectors. I am trying to find a way to implement a loop so that when I hit run, it will run for all the detectors at the same time without changing the other results like 'Corresponding Bin'.
Also, in order for the following codes to work, another set of codes must be opened at the same time, which I have already attached.
% THESE ARE MY USER INPUTS
numBins = 500;
desiredBin = 320;
dnum=1;
num_events = 100000;
moving_af = 50;
for hv= 1500:3:1800
% OBTAIN DATA
pulse_amps = ej309_ph_gen(hv+3, num_events, dnum);
%setting up the data for bins and counts
Bin= (0:2047/numBins:2047);
Cnts=histcounts(pulse_amps, Bin);
%moving average filters
windowWidth = round(moving_af);
kernel = ones(windowWidth,1) / windowWidth;
Count_plot = filter(kernel, 1, Cnts);
hold all %to hold current graph in the figure
[Y, X] = max (Count_plot); %plotting the max RHS peak
%if loop for desired bins with tolerances of ±10
if X>310 && X<330
break
end
end
%plotting the counts
hold all
plot(Count_plot);
plot(X,Y,'*');
%print off value for Bin
fprintf('The corresponding Bin is :%i\n', X);
%print off value for high voltage (hv)
fprintf('The corresponding hv is :%i\n', hv);
%print off value for detector number (dnum)
fprintf('The corresponding dnum is :%i\n',dnum);
I have been trying to use the while or for loop to create a loop for all the detector numbers (dnum) but every time I tried, it only returned the results for the last dnum and not results for other dnum.
Accepted Answer
More Answers (0)
Categories
Find more on AUTOSAR C++14 Rules 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!