SlideShare a Scribd company logo
1 of 2
Set up a MATlab program that puts the square of numbers from 1 to 20 in a one dimensional
array. The program will also sum all members of the array as well as compute the product of all
members. Output the values of the sum and product of all members. Do not use intrinsic
functions sum() and prod(.), this is not an array calculation. The lesson is about using the index
of an array so set up a “for― loop to do the calculations, which means each value is
obtained one at a time, as well as the sum and the product but still creates an array
Solution
1) To put square of 1 to 20 in one dimensional array
X = [1:20]
Y= X^2
2) To compute sum of all numbers
L=length(x); # takes the length of array
sum=0;
for i=1:L # to loop till length
sum=sum+x(i); sum of elements
y=sum;
3) To compute product of elements
L=length(x);
product=1;
for i=1:L
product=product*x(i);
y = product;

More Related Content

Similar to Set up a MATlab program that puts the square of numbers from 1 to 20 i.docx

Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxPremanandS3
 
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfaloeplusint
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Palak Sanghani
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlabAkshay Mistri
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in javaAbinaya B
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptximman gwu
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Randa Elanwar
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabvikrammutneja1
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in SwiftSaugat Gautam
 
Matrix operations in MATLAB
Matrix operations in MATLABMatrix operations in MATLAB
Matrix operations in MATLABSaloni Singhal
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013amanabr
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Kurmendra Singh
 

Similar to Set up a MATlab program that puts the square of numbers from 1 to 20 i.docx (20)

Mmc manual
Mmc manualMmc manual
Mmc manual
 
introduction to matlab.pptx
introduction to matlab.pptxintroduction to matlab.pptx
introduction to matlab.pptx
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
 
Matlab Tutorial.ppt
Matlab Tutorial.pptMatlab Tutorial.ppt
Matlab Tutorial.ppt
 
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlab
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Matlab
MatlabMatlab
Matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
 
Matrix operations in MATLAB
Matrix operations in MATLABMatrix operations in MATLAB
Matrix operations in MATLAB
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
 
Matlab for marketing people
Matlab for marketing peopleMatlab for marketing people
Matlab for marketing people
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 

More from todd161

For most people- pay is considered to be- For most people- pay is.docx
For most people- pay is considered to be-     For most people- pay is.docxFor most people- pay is considered to be-     For most people- pay is.docx
For most people- pay is considered to be- For most people- pay is.docxtodd161
 
For flow in a rectangular channel of height H and width W- the pressur.docx
For flow in a rectangular channel of height H and width W- the pressur.docxFor flow in a rectangular channel of height H and width W- the pressur.docx
For flow in a rectangular channel of height H and width W- the pressur.docxtodd161
 
For each row in the table below- decide whether the pair of elements w.docx
For each row in the table below- decide whether the pair of elements w.docxFor each row in the table below- decide whether the pair of elements w.docx
For each row in the table below- decide whether the pair of elements w.docxtodd161
 
For each of the following identify the type of account as an asset- li.docx
For each of the following identify the type of account as an asset- li.docxFor each of the following identify the type of account as an asset- li.docx
For each of the following identify the type of account as an asset- li.docxtodd161
 
For C++ 1-Provide an example of a simple function and discuss what it.docx
For C++ 1-Provide an example of a simple function and discuss what it.docxFor C++ 1-Provide an example of a simple function and discuss what it.docx
For C++ 1-Provide an example of a simple function and discuss what it.docxtodd161
 
for Arduino write a program to simulate the odd number count sequence-.docx
for Arduino write a program to simulate the odd number count sequence-.docxfor Arduino write a program to simulate the odd number count sequence-.docx
for Arduino write a program to simulate the odd number count sequence-.docxtodd161
 
For an object to appear green- what must the object do to green light.docx
For an object to appear green- what must the object do to green light.docxFor an object to appear green- what must the object do to green light.docx
For an object to appear green- what must the object do to green light.docxtodd161
 
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docx
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docxFor $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docx
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docxtodd161
 
FInd the zeros for the following polynomial function and give the mult.docx
FInd the zeros for the following polynomial function and give the mult.docxFInd the zeros for the following polynomial function and give the mult.docx
FInd the zeros for the following polynomial function and give the mult.docxtodd161
 
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxFind the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxtodd161
 
Find the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxFind the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxtodd161
 
Shen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxShen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxtodd161
 
Should OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxShould OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxtodd161
 
Social Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxSocial Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxtodd161
 
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxSirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxtodd161
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docxtodd161
 
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxSeveral years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxtodd161
 
Set up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxSet up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxtodd161
 
Soil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxSoil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxtodd161
 
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxSolution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxtodd161
 

More from todd161 (20)

For most people- pay is considered to be- For most people- pay is.docx
For most people- pay is considered to be-     For most people- pay is.docxFor most people- pay is considered to be-     For most people- pay is.docx
For most people- pay is considered to be- For most people- pay is.docx
 
For flow in a rectangular channel of height H and width W- the pressur.docx
For flow in a rectangular channel of height H and width W- the pressur.docxFor flow in a rectangular channel of height H and width W- the pressur.docx
For flow in a rectangular channel of height H and width W- the pressur.docx
 
For each row in the table below- decide whether the pair of elements w.docx
For each row in the table below- decide whether the pair of elements w.docxFor each row in the table below- decide whether the pair of elements w.docx
For each row in the table below- decide whether the pair of elements w.docx
 
For each of the following identify the type of account as an asset- li.docx
For each of the following identify the type of account as an asset- li.docxFor each of the following identify the type of account as an asset- li.docx
For each of the following identify the type of account as an asset- li.docx
 
For C++ 1-Provide an example of a simple function and discuss what it.docx
For C++ 1-Provide an example of a simple function and discuss what it.docxFor C++ 1-Provide an example of a simple function and discuss what it.docx
For C++ 1-Provide an example of a simple function and discuss what it.docx
 
for Arduino write a program to simulate the odd number count sequence-.docx
for Arduino write a program to simulate the odd number count sequence-.docxfor Arduino write a program to simulate the odd number count sequence-.docx
for Arduino write a program to simulate the odd number count sequence-.docx
 
For an object to appear green- what must the object do to green light.docx
For an object to appear green- what must the object do to green light.docxFor an object to appear green- what must the object do to green light.docx
For an object to appear green- what must the object do to green light.docx
 
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docx
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docxFor $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docx
For $129-000 Blizzard- Inc- acquired 10- of PLAINS Co--'s outstanding.docx
 
FInd the zeros for the following polynomial function and give the mult.docx
FInd the zeros for the following polynomial function and give the mult.docxFInd the zeros for the following polynomial function and give the mult.docx
FInd the zeros for the following polynomial function and give the mult.docx
 
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxFind the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
 
Find the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxFind the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docx
 
Shen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxShen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docx
 
Should OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxShould OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docx
 
Social Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxSocial Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docx
 
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxSirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
 
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxSeveral years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
 
Set up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxSet up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docx
 
Soil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxSoil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docx
 
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxSolution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 

Recently uploaded (20)

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 

Set up a MATlab program that puts the square of numbers from 1 to 20 i.docx

  • 1. Set up a MATlab program that puts the square of numbers from 1 to 20 in a one dimensional array. The program will also sum all members of the array as well as compute the product of all members. Output the values of the sum and product of all members. Do not use intrinsic functions sum() and prod(.), this is not an array calculation. The lesson is about using the index of an array so set up a “for― loop to do the calculations, which means each value is obtained one at a time, as well as the sum and the product but still creates an array Solution 1) To put square of 1 to 20 in one dimensional array X = [1:20] Y= X^2 2) To compute sum of all numbers L=length(x); # takes the length of array sum=0; for i=1:L # to loop till length sum=sum+x(i); sum of elements y=sum; 3) To compute product of elements L=length(x); product=1; for i=1:L product=product*x(i);