MATLAB: How to plot complex signal

complex signal

I'm very new to MatLab, how do i write a program in MatLab to plot : x(t) = cos (t) + j sin (t)
I was told it should be a circle but I'm seeing sinusoidal signal….
Thks in advance.
Mac. Goh

Best Answer

Try this
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
t = linspace(0, 2*pi, 90);
j = sqrt(-1);
complexSignal = cos(t) + j*sin (t)
% Get the real component and plot it on the x axis
x = real(complexSignal);
y = imag(complexSignal);
plot(x, y, 'bo-', 'LineWidth', 2);
grid on;
title('Plot of cos(t) + j*sin (t)', 'Fontsize', fontSize);
xlabel('Real Component', 'Fontsize', fontSize);
ylabel('Imaginary Component', 'Fontsize', fontSize);
axis square;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);