Hi taetae,
Your goal is to shoot a sine wave from each sensor's position towards a point and then sum these waves over rows to scan the terrain. The current code you've written aims to generate sine waves and combine them, but you are facing challenges with summing them over rows effectively. Here is an approach for combining sine waves over rows based on your code structure:
Fs = 10000; % Sampling Frequency
time_step = 1 / Fs;
gridSize = 10; % Define the number of sensor positions
L_values = rand(100, gridSize); % Define L_values with random values
max_time = max(L_values(:)); % Maximum time value
t = 0:time_step:max_time;
combined_pulse_data = zeros(gridSize, length(t));
% Generate sine waves and combine
for i = 1:100 for j = 1:gridSize pulse_time = L_values(i, j); if pulse_time > 0 pulse_index = round(pulse_time / time_step);
if pulse_index > 0 && pulse_index <= length(t)
% Generate sine wave
sine_wave = sin(2 * pi * 1000 * t(1:end-pulse_index+1));
% Sum over rows efficiently
combined_pulse_data(j, pulse_index:end) = combined_pulse_data(j, pulse_index:end) + sine_wave; end end end end
% Display the results
figure;
imagesc(t, 1:gridSize, combined_pulse_data);
colorbar;
xlabel('Time');
ylabel('Sensor Position');
title('Combined Sine Waves for Topographic Scanning');
The above code snippet initializes parameters like sampling frequency, time steps, grid size, and random L_values. It then calculates the maximum time value and generates sine waves based on pulse times. The sine waves are summed efficiently over rows to create combined pulse data for each sensor position. Finally, the results are displayed as an image showing the combined sine waves over time and sensor positions. Feel free to customize this solution further based on your specific needs or additional functionalities required.
Please see attached code snippet generated in Matlab along with the plot.
Please let me know if you have any further questions.