Uploaded by Vraj Shah

MAE321 Recitation 2 work

advertisement
% Vraj Shah
% MAE321
% Recitation #2 Work
clear all
close all
clc
Problem 1
% Plot function using for loop method
x = [-3:.1:3];
i = 1;
for i = length(x)
y = x .^2;
i + 1;
end
figure(1)
plot(x,y)
hold on
plot(x,y,'o')
hold on
xlabel('X Axis')
ylabel('Y Axis')
title('Plot of y = x^2 using for loop method')
legend('Curve','Data Points','Location','Southeast')
1
Problem 2
x = [-3:.1:3];
y = x.^2;
figure(2)
plot(x,y)
hold on
plot(x,y,'o')
hold on
xlabel('X Axis')
ylabel('Y Axis')
title('Plot of y = x^2 using element multiplication')
legend('Curve','Data Points','Location','Southeast')
2
Published with MATLAB® R2020b
3
Download