Question
can anyone help with a MatLab code?
Problem create a function that takes in the following vector DATA and returns the number of elements, the mean and the sum of
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following syntax will be used in the desired coding.

  1. DATA= input('Enter the sequence'); It will ask you to enter a number. You have to enter the desired no DATA as required. Or u candirectly enter the value as DATA=  [2 4 5 6 7 8] in the editor itself.
  2. n= numel(DATA); it Return the number of elements of DATA . In this case it returns 6.
  3. S= sum(DATA); it Return the sum of the DATA . in this case it returns- 2+4+5+6+7+8= 32
  4. M= mean(DATA); it Return the mean of the DATA. in this case it returns , sum/ 6 . i.e 32divided by 6 = 5.33.

The complete Matlab function:

% Enter the DATA
DATA= input('Enter the sequence');

% Return the number of elements of DATA
n= numel(DATA);

% Return the mean of the DATA
M= mean(DATA);

% Return the sum of the DATA
S= sum(DATA);

Attaching the screen- shot also

Function is written on the Editor.

DATA value is entering through Command Window.

Values of no of elements (n), sum(S) and mean (M) returning in Workplace  

Add a comment
Know the answer?
Add Answer to:
can anyone help with a MatLab code? Problem create a function that takes in the following...
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