Clear Filters
Clear Filters

Anybody please share the matlab code for feeding two different waveform to two different array elements. Thanks.

2 views (last 30 days)
Signal Processing

Answers (1)

Amith
Amith on 28 Feb 2023
As per my understanding you wanted to know how to feed two different waveforms as two different elements of an array .So here is an example on how to do that
% Define parameters
f1 = 1e3; % Frequency of the first waveform
f2 = 2e3; % Frequency of the second waveform
t = linspace(0,1,100) % Time vector
% Create the two waveforms
waveform1 = sin(2*pi*f1*t);
waveform2 = cos(2*pi*f2*t);
% Create the array with two elements
array = zeros(2, length(t));
% Assign the waveforms to the array elements
array(1, :) = waveform1;
array(2, :) = waveform2;
% Plot the waveforms
subplot(2,1,1)
plot(t, waveform1)
xlabel('Time (s)')
ylabel('Amplitude')
title('Waveform 1')
subplot(2,1,2)
plot(t, waveform2)
xlabel('Time (s)')
ylabel('Amplitude')
title('Waveform 2')
This code creates two waveforms with frequencies of 1 kHz and 2 kHz, and then assigns them to the first and second element of an array, respectively. The code then plots the two waveforms separately for visualization.
You can modify the code to create and assign different waveforms to the array elements as needed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!