Question

Solve in MATLAB

Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all e

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For more information, refer to Matlab Online Library or drop a comment below. Please give a Thumbs Up, if solution is helpful.

Solution :

The matlab code to perform the required tasks is as follows,

clc;
clear;

x = [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 5];
sumX = 0;

for i = 1:length(x)
  
sumX = sumX + x(i);
y(i) = sumX;

end


disp(['Sum of X is) is : ',num2str(sumX)]);
disp(['Y(16) is : ',num2str(y(16))]);

And the results for Q.5 and Q.6 is,

Command Window Sum of X is) is: 87 Y(16) is 60 f>

NOTE : Feel free to ask further queries. Your positive rating would be appreciated and motivate me !

Add a comment
Know the answer?
Add Answer to:
Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT