Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

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

 

Step by Step Solution

3.46 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

MATLAB CODE clearclc close all tst0t... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Discuss why Agency Funds do not have a fund balance.

Answered: 1 week ago