MATLAB: How to generate random amplitude pulse signal pulse amplitude Hi all, I want to make a series of signal of 10 pulses but each pulses have different amplitude. The repitition rate: 50kHz Pulse width: 5ns Thanks! Best Answer Try this. It generates a periodic pulse with width of 5 ns and random amplitude.fs = 50000; % 50 kHz frequencyTs = 1/fs*10^9; % sample rate in neno secondst = 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);xlabel('Time (ns)');ylabel('Amplitude'); Related SolutionsMATLAB: How could I use if function to update the newest maximum value Try thisfs = 50000; % 50 kHz frequencyTs = 1/fs*10^9; % sample rate in neno secondst = 1:Ts;pulse = t<=5;rand_amp = rand(10,1);sig = pulse.*rand_amp;sig = reshape(sig', [], 1);max_val = zeros(size(sig)); % save maximum value at each time step;max_val(1) = sig(1); % first maximum value is the first sample of sigfor i=2:numel(max_val) if sig(i) > max_val(i-1) max_val(i) = sig(i); else max_val(i) = max_val(i-1); endendt_total = 1:numel(sig);figure;plot(t_total, sig);xlabel('Time (ns)');ylabel('Amplitude');figure;plot(t_total, max_val);xlabel('Time (ns)');ylabel('Amplitude'); MATLAB: For Loop in Data x = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ];y = cell(1, 4);for k = 1:4 y{k} = x(1-k:end) - x(1:end-k);endPrefer a cell array instead of hiding indices in the names of variables. Related QuestionI am getting the following error for the below code: Subscript indices must either be real positive integers or logicals. How can i remove that error.What’s the best way to add semi-colons after each element of a matrix
Best Answer