MATLAB Develop a vectorized version of the following code: tst = 0; tnd = 20; ni=5; t(1)=tst;
Fantastic news! We've Found the answer you've been seeking!
Question:
MATLAB
Develop a vectorized version of the following code:
tst = 0; tnd = 20; ni=5;
t(1)=tst;
y(1)=15 + 5*cos(2*pi*t(1)/(tnd-tst));
for i=2:ni+1
t(i) = t(i-1) + (tnd - tst)/ni;
y(i) = 15 + 5*cos(2*pi*t(i)/(tnd - tst));
end
Write this as an M-file. Here, you are supposed to be slick and get rid of the for-loop. Hint:
x=2:4:10 is the vectorized version of the for-loop
for i = 1:3
x(i) = 2+4*(i-1);
end
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Most organizations do not have a single, centralized system that shares data across all transaction processes. Instead, organizations tend to have different systems for different processes or...
-
Discuss why Agency Funds do not have a fund balance.
-
Some ions do not have a corresponding neutral atom that has the same electron configuration. For each of the following ions, identify the neutral atom that has the same number of electrons and...
-
Describe the risk assessment approach used for Enterprise Risk Management(ERM) at Worker's Compensation Fund(WCF). How does this approach compare to ISO 31000? Does it consider risks with upside...
-
Bartow Photographic Services takes wedding and graduation photographs. At December 31, the end of Bartows accounting period, the following information is available: a. All wedding photographs are...
-
A 12.0-m-long steel beam is accidentally dropped by a construction crane from a height of 9.00 m. The horizontal component of the Earths magnetic field over the region is 18.0 T. What is the induced...
-
What are the differences between average hourly earnings and the employment cost index?
-
Francisco Inc. acquired 100 percent of the voting shares of Beltran Company on January 1, 2014. In exchange, Francisco paid $450,000 in cash and issued 104,000 shares of its own $1 par value common...
-
(a) A company has an EPS of Rs. 2.5 for the last year and the DPS of Rs. 1. The earnings is expected to grow at 2% a year in long run. Currently it is trading at 7 times its earnings. If the required...
-
Design a clamper to perform the function indicated in Fig. 2.180. Silicon diodes 10 V 2.7 V vV Design -10 V
-
How does your organization use research? How might your organization expand its use of research? If you are not currently practicing, how do you think organizations should use research?
-
Define and explain double linked list with a suitable example.
-
What is the difference between malloc() and calloc() dynamic memory management functions?
-
What are the major differences between the linked list and linear array?
-
How does choice expand power and freedom?
-
Explain the generic pointer with a suitable example.
-
Black & Decker is a company that makes tools for using around the house such as drills and hammers. Recently they decided to create toy tools for children such as a small plastic hammer for a toddler...
-
Data on weekday exercise time for 20 females, consistent with summary quantities given in the paper An Ecological Momentary Assessment of the Physical Activity and Sedentary Behaviour Patterns of...
-
A candlestick chart is similar to a bar chart except that the candlestick chart: A. Represents upward movements in price with Xs. B. Also graphically shows the range of the periods highs and lows. C....
-
What considerations might encourage a market analyst to rely more on a top-down or bottom-up forecast of S&P 500 operating earnings?
-
Which of the following criticisms expressed by Ryan about the use of historical data is the least valid? A. In a context of hyperinflation, the approach may not be appropriate. B. The companies...
Study smarter with the SolutionInn App