Question: Compare and contrast the two methods used to generate the two MATLAB arrays x 1 and x 2 in the following MATLAB code: % T

Compare and contrast the two methods used to generate the two MATLAB arrays x1 and x2 in the following MATLAB code:
% T. Obuchowicz
%Fri Apr 2716:03:27 EDT 2012
clear
n =[1 : 20]
x1= sin((2*pi/40)* n).* cos((2*pi/40)* n) for index =1 : 20
% Note: In MATLAB, no need to pre-allocate the array,
% unlike C++ and other high-level programming languages. x2(index)= sin((2*pi/40)* index)* cos((2*pi/40)* index)
end
subplot(2,1,1) stem(n, x1)
title(Elegant method making full use of MATLABs array capabilities) xlabel(n)
ylabel(x[n])
subplot(2,1,2) stem(n, x2)
title(Gets the job done, but it is a lot of work and we are not in the MATLAB mindset)
xlabel(n) ylabel(x[n])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!