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)
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Mobile Communications
Authors: Jochen Schiller
2nd edition
978-0321123817, 321123816, 978-8131724262
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App