Hi all,
I am going to use photodiode to monitor my laser and capture the max power during the machine is operating.
So, I write the code to generate similar signal and want to build a tool for me can always update the maximum value in the real time.
I have thought about using "if" to update the max value when the latest one is higher but not sure how to implemente it?
Here is my code below, I used rand() to produce random amplitude signal:
fs = 50000; % 50 kHz frequency
Ts = 1/fs*10^9; % sample rate in neno seconds
t = 1:Ts;pulse = t<=5;rand_amp = rand(10,1);sig = pulse.*rand_amp;sig = reshape(sig', [], 1);t_total = 1:numel(sig);plot(t_total, sig);%find the maximum
maxPulse= max(sig);xlabel('Time (ns)');ylabel('Amplitude');
Best Answer