Question: Part A . 5 marks We wish to compute a row vector of n = 1 0 0 0 0 0 0 entries, where entry

Part A.5 marks
We wish to compute a row vector of n =1000000 entries, where entry I of the vector equals 1/n sin (ipi/n). We apply the following approaches:
A1: The vector u is created using a for-loop without pre-initializing the array.
A2: The vector v is created using a for-loop and it is first pre-initialized using Matlabs zeros command.
A3: The vector w is created without using a loop.
Use Matlabs tic and toc to measure the time required for each approach. (Include the pre-initialization for vector v.) Determine which method is the most efficient and which method is least efficient. Is there a significant difference in the compute time?

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!