0% found this document useful (0 votes)
39 views

MATLAB Exam

This MATLAB code defines time, x, y, and z variables as functions of t and performs calculations. It then creates a 2x2 subplot with the first plotting x, y, and z in 3D; the second plotting x and y in 2 planes; the third plotting x and z; and the fourth plotting y and z. Each subplot contains two plots, one in blue and one in green, with titles, labels, and a grid.
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)
39 views

MATLAB Exam

This MATLAB code defines time, x, y, and z variables as functions of t and performs calculations. It then creates a 2x2 subplot with the first plotting x, y, and z in 3D; the second plotting x and y in 2 planes; the third plotting x and z; and the fourth plotting y and z. Each subplot contains two plots, one in blue and one in green, with titles, labels, and a grid.
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
You are on page 1/ 2

5/2/16 7:03 PM

function [

C:\Users\GilmoreJ1178\Downloads\Exam3_1.m

] = Exam3_1(

% 3D Plot Example
t = 0:0.1:10*pi;
x = t.* sin(2.*t);
y = t.*(cos(t) + sin(t));
z = (cos(t) .* sin(t));
z1 = t * .1;

%
%
%
%
%

Set the time array


Calcualte x
Calcualte y
Calcualte z
Calcualte z1

% Subplot 1 - Plot x, y, z
subplot(2, 2, 1);
plot3(x,y, z);
hold on;
plot3(x, y, z1, 'g');
grid on;
title ('3D plot');
xlabel ('t.* sin(2.*t)');
ylabel ('t.*(cos(t) + sin(t))');
zlabel ('(cos(t) .* sin(t))');
% Subplot 2 - Plot x, y
subplot(2, 2, 2)
plot(x, y, 'b');
hold on;
plot(x, y, 'g');
grid on;
title ('x - y plane');
xlabel ('t.* sin(2.*t)');
ylabel ('t.*(cos(t) + sin(t))');
% Subplot 3 - Plot x, z
subplot(2, 2, 3);
plot(x, z);
hold on;
plot(x, z1, 'g');
grid on;
title ('x - z');
xlabel ('t.* sin(2.*t)');
ylabel ('(cos(t) .* sin(t))');
% Subplot 4 - Plot y, z
subplot(2, 2, 4);
plot(y, z);
hold on;
plot (y, z1, 'g');
grid on;
title ('y - z');
xlabel ('t.*(cos(t) + sin(t))');
ylabel ('(cos(t) .* sin(t))');

1 of 2

5/2/16 7:03 PM
end

C:\Users\GilmoreJ1178\Downloads\Exam3_1.m

2 of 2

You might also like