SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Similar a 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
 

Similar a 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
 

Más 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
 

Más 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
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
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
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 

Último (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
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
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

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