0% found this document useful (0 votes)
3 views2 pages

Problem1 Plotting

This document outlines a MATLAB script for plotting four mathematical functions in a 2x2 subplot grid. Each subplot features a different function with specified styles, colors, and grid settings. The script concludes with a message indicating the completion of the plot.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Problem1 Plotting

This document outlines a MATLAB script for plotting four mathematical functions in a 2x2 subplot grid. Each subplot features a different function with specified styles, colors, and grid settings. The script concludes with a message indicating the completion of the plot.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

% Engineering Models I - Homework Assignment #2

% Problem 1: Plotting Functions in 2x2 subplot grid


% Instructions followed: using subplot, no Plot Tools, good axis choices,
% solid/dashed styles, grids where specified, no individual data points marked

clear; clc; close all;

% Create main figure


figure('Name', 'Problem 1 - Four Functions', 'NumberTitle', 'off');

% (a) Top Left: y = t² - 4t + 3 solid yellow line - grid


subplot(2,2,1);
t_a = -1:0.1:5; % good range to show the parabola clearly
y_a = t_a.^2 - 4*t_a + 3;
plot(t_a, y_a, 'y-', 'LineWidth', 2);
grid on;
title('y = t^2 - 4t + 3', 'FontSize', 11);
xlabel('t', 'FontSize', 10);
ylabel('y', 'FontSize', 10);
set(gca, 'Box', 'on');

% (b) Top Right: y = cos(4t) dashed white line


subplot(2,2,2);
t_b = 0:0.01:2*pi; % 0 to ~2 periods is a good view
y_b = cos(4*t_b);
plot(t_b, y_b, 'w--', 'LineWidth', 2);
title('y = cos(4t)', 'FontSize', 11);
xlabel('t', 'FontSize', 10);
ylabel('y', 'FontSize', 10);
grid on;

% (c) Bottom Left: y = e^{-t^2} dashed magenta line - grid


subplot(2,2,3);
t_c = -3:0.05:3; % symmetric around 0, captures Gaussian shape
y_c = exp(-t_c.^2);
plot(t_c, y_c, 'm--', 'LineWidth', 2);
grid on;
title('y = e^{-t^2}', 'FontSize', 11);
xlabel('t', 'FontSize', 10);
ylabel('y', 'FontSize', 10);
set(gca, 'Box', 'on');

% (d) Bottom Right: y = sin(2\pi t) * sin(20\pi t) solid green line, t = 0


to 2 s
subplot(2,2,4);
t_d = 0:0.001:2; % fine step to show fast oscillations clearly
y_d = sin(2*pi*t_d) .* sin(20*pi*t_d);
plot(t_d, y_d, 'g', 'LineWidth', 2);
title('y = sin(2\pi t) \cdot sin(20\pi t)', 'FontSize', 11);
xlabel('t (0 to 2 s)', 'FontSize', 10);
ylabel('y', 'FontSize', 10);
grid on;

1
% Optional: overall figure title (does not affect grading)
sgtitle('Problem 1: Plotting Four Functions', 'FontSize', 13);

% End of script
disp('Plot complete. Check the figure window.');

Plot complete. Check the figure window.

Published with MATLAB® R2025b

You might also like