Below you will find MATLAB code for 3D Visualization of a simulated brain signal.

## MATLAB Code

t = linspace(0, 2*pi, 1000);

frequency = 1;

amplitude_cos = 1;

amplitude_sawtooth = 0.5;

brain_signal = amplitude_cos * cos(2*pi*frequency*t) + amplitude_sawtooth * sawtooth(2*pi*frequency*t);

figure;

plot(t, brain_signal, ‘LineWidth’, 2);

title(‘Simulated Brain Signal’);

xlabel(‘Time (s)’);

ylabel(‘Amplitude’);

grid on;

figure;

subplot(2, 1, 1);

plot(t, amplitude_cos * cos(2*pi*frequency*t), ‘LineWidth’, 2);

title(‘Cosine Component’);

xlabel(‘Time (s)’);

ylabel(‘Amplitude’);

grid on;

subplot(2, 1, 2);

plot(t, amplitude_sawtooth * sawtooth(2*pi*frequency*t), ‘LineWidth’, 2);

title(‘Sawtooth Component’);

xlabel(‘Time (s)’);

ylabel(‘Amplitude’);

grid on;

## Output

Note that when you run the code on MATLAB, you will get two displays/outputs. One of these will be the figure you see above.

The second is attached below. This is because the same code obtains cosine component and sawtooth wave of the simulated brain signal.

Need to understand the code? Comment below!

If you’re looking for more lab tasks for signals and systems using MATLAB, browse these:

## Leave a Reply