SlideShare une entreprise Scribd logo
1  sur  3
2. Write a MATLAB program that calculates the arithmetic mean, the geometric mean, and the
root-mean-square average for a given set of values. Your program must use 3 functions to
calculate the 3 required means. The output should be formatted as follows:
Your name Statistical Package arithmetic mean = x.xxxxx geometric mean = x.xxxxx RMS
average = x.xxxxx
Test your program on the following values: 1.1, 3.3, 3.00, 2.22, 2.00, 2.72, 4.00, 4.62 and 5.37.
Your main program calls 3 functions.
The data should be read by the main program from a text file, stored in an array and then passed
to the functions.
The results and any other output should be printed by the main program. Notice how the output
results are aligned. Also notice that the results are printed accurate to 5 decimal places.
DO NOT USE MATLAB BUILT-IN FUNCTIONS.
I am stumped on this problem as I am not to good with creating functions in matlab
Solution
I am going to give you 4 files, three functions and one script. Create 4 new scripts in matlab and
save them as given. Then run the "Mean.m" script.
Mean.m
fid = fopen('input.txt');
Array = fscanf(fid, '%g');
Amean = AM(Array);
Gmean = GM(Array);
Rmean = RMS(Array);
display('Amlan Das Statistical Package')
display(['arithmetic mean = ', sprintf('%.5f',Amean)]);
disp(['geometric mean = ', sprintf('%.5f',Gmean)]);
disp(['RMS average = ', sprintf('%.5f',Rmean)]);
AM.m
function [ AMean ] = AM( Array )
n = length(Array);
AMean = 0;
for i = 1:n
AMean = AMean + Array(i);
end
AMean = AMean/n;
end
GM.m
function [ GMean ] = GM(Array)
n = length(Array);
GMean = 1;
for i = 1:n
GMean = GMean*Array(i);
end
GMean = GMean^(1/n);
end
RMS.m
function [ RMean ] = RMS( Array)
n = length(Array);
RMean = 0;
for i = 1:n
RMean = RMean + Array(i)^2;
end
RMean = (RMean/n)^(0.5);
end
2- Write a MATLAB program that calculates the arithmetic mean- the geo.docx

Contenu connexe

Similaire à 2- Write a MATLAB program that calculates the arithmetic mean- the geo.docx

matlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxmatlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxlekhacce
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systemsRaghav Shetty
 
Introduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxIntroduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxMMCOE, Karvenagar, Pune
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codepradesigali1
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfmallik3000
 
1126640 question
1126640 question 1126640 question
1126640 question lpss0513
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab sessionDr. Krishna Mohbey
 
Introduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfIntroduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfDrAzizulHasan1
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab OverviiewNazim Naeem
 
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make YASHU40
 

Similaire à 2- Write a MATLAB program that calculates the arithmetic mean- the geo.docx (20)

matlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsxmatlab-130408153714-phpapp02_lab123.ppsx
matlab-130408153714-phpapp02_lab123.ppsx
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
Introduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxIntroduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptx
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdf
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
 
pyton Notes9
pyton Notes9pyton Notes9
pyton Notes9
 
1126640 question
1126640 question 1126640 question
1126640 question
 
Basic matlab for beginners
Basic matlab for beginnersBasic matlab for beginners
Basic matlab for beginners
 
Matlab functions
Matlab functionsMatlab functions
Matlab functions
 
Matlab practical and lab session
Matlab practical and lab sessionMatlab practical and lab session
Matlab practical and lab session
 
Project
ProjectProject
Project
 
Introduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdfIntroduction to Matlab for Engineering Students.pdf
Introduction to Matlab for Engineering Students.pdf
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab Overviiew
 
Mat-lab image processing tatorial
Mat-lab  image processing tatorialMat-lab  image processing tatorial
Mat-lab image processing tatorial
 
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
 
Matlab pt1
Matlab pt1Matlab pt1
Matlab pt1
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make
 

Plus de todd621

4) What is the Reynolds number- Give an equation but also an explanati.docx
4) What is the Reynolds number- Give an equation but also an explanati.docx4) What is the Reynolds number- Give an equation but also an explanati.docx
4) What is the Reynolds number- Give an equation but also an explanati.docxtodd621
 
3- After water vapor- CO2 is the next most important atmospheric trace.docx
3- After water vapor- CO2 is the next most important atmospheric trace.docx3- After water vapor- CO2 is the next most important atmospheric trace.docx
3- After water vapor- CO2 is the next most important atmospheric trace.docxtodd621
 
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docxtodd621
 
2014 2013 LINK TO TEXT LINK TO TEXT The following account b.docx
2014 2013 LINK TO TEXT LINK TO TEXT            The following account b.docx2014 2013 LINK TO TEXT LINK TO TEXT            The following account b.docx
2014 2013 LINK TO TEXT LINK TO TEXT The following account b.docxtodd621
 
2- There are 3 mechanisms of heat transfer and all are important in ma.docx
2- There are 3 mechanisms of heat transfer and all are important in ma.docx2- There are 3 mechanisms of heat transfer and all are important in ma.docx
2- There are 3 mechanisms of heat transfer and all are important in ma.docxtodd621
 
2- Marvin Services Corporation had the following accounts and balances.docx
2- Marvin Services Corporation had the following accounts and balances.docx2- Marvin Services Corporation had the following accounts and balances.docx
2- Marvin Services Corporation had the following accounts and balances.docxtodd621
 
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docxtodd621
 
18- Ray was chosen by his boss to lead a team of coworkers during a co.docx
18- Ray was chosen by his boss to lead a team of coworkers during a co.docx18- Ray was chosen by his boss to lead a team of coworkers during a co.docx
18- Ray was chosen by his boss to lead a team of coworkers during a co.docxtodd621
 
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docxtodd621
 

Plus de todd621 (9)

4) What is the Reynolds number- Give an equation but also an explanati.docx
4) What is the Reynolds number- Give an equation but also an explanati.docx4) What is the Reynolds number- Give an equation but also an explanati.docx
4) What is the Reynolds number- Give an equation but also an explanati.docx
 
3- After water vapor- CO2 is the next most important atmospheric trace.docx
3- After water vapor- CO2 is the next most important atmospheric trace.docx3- After water vapor- CO2 is the next most important atmospheric trace.docx
3- After water vapor- CO2 is the next most important atmospheric trace.docx
 
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx
2014 Health Savings Accounts (HSA) Exam - Scenario 4- Carlos and Julie.docx
 
2014 2013 LINK TO TEXT LINK TO TEXT The following account b.docx
2014 2013 LINK TO TEXT LINK TO TEXT            The following account b.docx2014 2013 LINK TO TEXT LINK TO TEXT            The following account b.docx
2014 2013 LINK TO TEXT LINK TO TEXT The following account b.docx
 
2- There are 3 mechanisms of heat transfer and all are important in ma.docx
2- There are 3 mechanisms of heat transfer and all are important in ma.docx2- There are 3 mechanisms of heat transfer and all are important in ma.docx
2- There are 3 mechanisms of heat transfer and all are important in ma.docx
 
2- Marvin Services Corporation had the following accounts and balances.docx
2- Marvin Services Corporation had the following accounts and balances.docx2- Marvin Services Corporation had the following accounts and balances.docx
2- Marvin Services Corporation had the following accounts and balances.docx
 
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx
2- The following are types of organisms- A- bacteria- B- fungi- C- alg.docx
 
18- Ray was chosen by his boss to lead a team of coworkers during a co.docx
18- Ray was chosen by his boss to lead a team of coworkers during a co.docx18- Ray was chosen by his boss to lead a team of coworkers during a co.docx
18- Ray was chosen by his boss to lead a team of coworkers during a co.docx
 
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx
2- Accepted $16-700 on February 1- 2014- as a retainer for services to.docx
 

Dernier

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 

Dernier (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 

2- Write a MATLAB program that calculates the arithmetic mean- the geo.docx

  • 1. 2. Write a MATLAB program that calculates the arithmetic mean, the geometric mean, and the root-mean-square average for a given set of values. Your program must use 3 functions to calculate the 3 required means. The output should be formatted as follows: Your name Statistical Package arithmetic mean = x.xxxxx geometric mean = x.xxxxx RMS average = x.xxxxx Test your program on the following values: 1.1, 3.3, 3.00, 2.22, 2.00, 2.72, 4.00, 4.62 and 5.37. Your main program calls 3 functions. The data should be read by the main program from a text file, stored in an array and then passed to the functions. The results and any other output should be printed by the main program. Notice how the output results are aligned. Also notice that the results are printed accurate to 5 decimal places. DO NOT USE MATLAB BUILT-IN FUNCTIONS. I am stumped on this problem as I am not to good with creating functions in matlab Solution I am going to give you 4 files, three functions and one script. Create 4 new scripts in matlab and save them as given. Then run the "Mean.m" script. Mean.m fid = fopen('input.txt'); Array = fscanf(fid, '%g'); Amean = AM(Array); Gmean = GM(Array); Rmean = RMS(Array); display('Amlan Das Statistical Package') display(['arithmetic mean = ', sprintf('%.5f',Amean)]);
  • 2. disp(['geometric mean = ', sprintf('%.5f',Gmean)]); disp(['RMS average = ', sprintf('%.5f',Rmean)]); AM.m function [ AMean ] = AM( Array ) n = length(Array); AMean = 0; for i = 1:n AMean = AMean + Array(i); end AMean = AMean/n; end GM.m function [ GMean ] = GM(Array) n = length(Array); GMean = 1; for i = 1:n GMean = GMean*Array(i); end GMean = GMean^(1/n); end RMS.m function [ RMean ] = RMS( Array) n = length(Array); RMean = 0; for i = 1:n RMean = RMean + Array(i)^2; end RMean = (RMean/n)^(0.5); end