MATLAB Assignment – Final Complete Script
Student Name: ____________________
Student ID: ____________________
Course Title: ____________________
Instructor Name: ____________________
Final MATLAB Script
clc;
clear;
close all;
% Declare vector X
X = [1 2 3 4 5 6 7 8 9];
% Declare vector Y1 using Student ID digits
Y1 = [2 1 0 3 4 5 6 7 8];
% Declare vector Y2 using reverse Student ID digits
Y2 = [8 7 6 5 4 3 0 1 2];
% Plot first line
plot(X, Y1, 'r-*');
% Hold figure for second plot
hold on;
% Plot second line
plot(X, Y2, 'b-*');
% Add labels
xlabel('X');
ylabel('Y1 and Y2');
% Add title
title('Student ID = MC210345678');
% Add legend
legend('My Student ID', 'MY Student ID in Reverse');
% Turn grid on
grid on;
% Save figure in JPG format
saveas(gcf, '[Link]');
Explanation
This MATLAB program creates two vectors using the student ID digits and their reverse
order. Both vectors are plotted on the same graph using different colors and asterisk
markers. The graph also contains labels, title, legend, and grid. Finally, the figure is saved in
JPG format.