SlideShare a Scribd company logo
How do I transfer this m-file to make it into a Function m-file in MATLAB? This is the only
thing i have left before i turn in my project, if you can help me clear this up i would appreciate it.
clear all;
a=input('Enter any desired row vector in []:');
n=length(a);
for ii=1:n
fprintf('ii = %d  ', ii);
for jj = 1:n
fprintf(' jj = %d  ', jj);
for kk=1:n
fprintf(' kk = %d  ', kk);
A(ii,jj)= a(ii)*a(jj)*a(kk);
end
end
end
A
plot(A)
I keep getting these errors:
Line 1: Invalid syntax at 'Enter any desired row vector in []:'. Possibly, a ), } , or ] is missing.
Line 1: Parse error at ')' : usage might be invalid MATLAB syntax
! Line 1: The function return value 'a' might be unset.
Solution
ANSWER:
To convert a piece of code into a function to which parameters can be passed the folowing is the
syntax to be used.
function func_name(variable) where func_name is the name of the function we intend to keep
and variable is the variable to be passed to the function.
function assignment(a)
clear all;
n=length(a);
for ii=1:n
fprintf('ii = %d  ', ii);
for jj = 1:n
fprintf(' jj = %d  ', jj);
for kk=1:n
fprintf(' kk = %d  ', kk);
A(ii,jj)= a(ii)*a(jj)*a(kk);
end
end
end
plot(A);
The above change has to be incorporated.

More Related Content

Similar to How do I transfer this m-file to make it into a Function m-file in MAT.docx

Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
aboma2hawi
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
MOHAMMAD SAYDUL ALAM
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
mydrynan
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
MahuaPal6
 
Matlab practice
Matlab practiceMatlab practice
Matlab practice
ZunAib Ali
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
gilpinleeanna
 
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
Randa Elanwar
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
محمدعبد الحى
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
KrishnaChaitanya139768
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
SudhirNayak43
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
ManasaChevula1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Mohan Raj
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
Ranjan Pal
 
vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarh
matrixphagwara
 
6 weeks summer training in matlab,jalandhar
6 weeks summer training in matlab,jalandhar6 weeks summer training in matlab,jalandhar
6 weeks summer training in matlab,jalandhar
deepikakaler1
 
data mining training in Bangalore
data mining training in Bangaloredata mining training in Bangalore
data mining training in Bangalore
matrixphagwara
 
6months industrial training in matlab, jalandhar
6months industrial training in matlab, jalandhar6months industrial training in matlab, jalandhar
6months industrial training in matlab, jalandhar
deepikakaler1
 
MATLAB guide
MATLAB guideMATLAB guide
MATLAB guide
Prerna Rathore
 

Similar to How do I transfer this m-file to make it into a Function m-file in MAT.docx (20)

Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
Matlab practice
Matlab practiceMatlab practice
Matlab practice
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
 
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
 
vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarh
 
6 weeks summer training in matlab,jalandhar
6 weeks summer training in matlab,jalandhar6 weeks summer training in matlab,jalandhar
6 weeks summer training in matlab,jalandhar
 
data mining training in Bangalore
data mining training in Bangaloredata mining training in Bangalore
data mining training in Bangalore
 
6months industrial training in matlab, jalandhar
6months industrial training in matlab, jalandhar6months industrial training in matlab, jalandhar
6months industrial training in matlab, jalandhar
 
Matlab tut2
Matlab tut2Matlab tut2
Matlab tut2
 
MATLAB guide
MATLAB guideMATLAB guide
MATLAB guide
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
 

More from cliftonl1

How many dance steps would the square have-and-Construct a multiplicat.docx
How many dance steps would the square have-and-Construct a multiplicat.docxHow many dance steps would the square have-and-Construct a multiplicat.docx
How many dance steps would the square have-and-Construct a multiplicat.docx
cliftonl1
 
How has the physician-patient relationship changed over the past centu.docx
How has the physician-patient relationship changed over the past centu.docxHow has the physician-patient relationship changed over the past centu.docx
How has the physician-patient relationship changed over the past centu.docx
cliftonl1
 
How is treasury stock shown on the balance sheet- Treasury stock is no.docx
How is treasury stock shown on the balance sheet- Treasury stock is no.docxHow is treasury stock shown on the balance sheet- Treasury stock is no.docx
How is treasury stock shown on the balance sheet- Treasury stock is no.docx
cliftonl1
 
How is repetition of components different from redundancy- How are the.docx
How is repetition of components different from redundancy- How are the.docxHow is repetition of components different from redundancy- How are the.docx
How is repetition of components different from redundancy- How are the.docx
cliftonl1
 
How is communication a part of best practices-Solution4 Leadership Bes.docx
How is communication a part of best practices-Solution4 Leadership Bes.docxHow is communication a part of best practices-Solution4 Leadership Bes.docx
How is communication a part of best practices-Solution4 Leadership Bes.docx
cliftonl1
 
How does the National Society of Professional Engineers Code of Ethics.docx
How does the National Society of Professional Engineers Code of Ethics.docxHow does the National Society of Professional Engineers Code of Ethics.docx
How does the National Society of Professional Engineers Code of Ethics.docx
cliftonl1
 
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docxhow does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
cliftonl1
 
How does the evolution of attack tools affect existing systems- What s.docx
How does the evolution of attack tools affect existing systems- What s.docxHow does the evolution of attack tools affect existing systems- What s.docx
How does the evolution of attack tools affect existing systems- What s.docx
cliftonl1
 
How do you think the DATA Act will impact governmental entities and st.docx
How do you think the DATA Act will impact governmental entities and st.docxHow do you think the DATA Act will impact governmental entities and st.docx
How do you think the DATA Act will impact governmental entities and st.docx
cliftonl1
 
How do I determine the Rf Value with just the information I have provi.docx
How do I determine the Rf Value with just the information I have provi.docxHow do I determine the Rf Value with just the information I have provi.docx
How do I determine the Rf Value with just the information I have provi.docx
cliftonl1
 
How do I print a list of payroll checks for the calendar year to date.docx
How do I print a list of payroll checks for the calendar year to date.docxHow do I print a list of payroll checks for the calendar year to date.docx
How do I print a list of payroll checks for the calendar year to date.docx
cliftonl1
 
How does SO2 in the atmosphere affect global warming- In general- what.docx
How does SO2 in the atmosphere affect global warming- In general- what.docxHow does SO2 in the atmosphere affect global warming- In general- what.docx
How does SO2 in the atmosphere affect global warming- In general- what.docx
cliftonl1
 
How does an awareness of the historical link between the United States.docx
How does an awareness of the historical link between the United States.docxHow does an awareness of the historical link between the United States.docx
How does an awareness of the historical link between the United States.docx
cliftonl1
 
How do you utilize PM software to manage team activities-SolutionProje.docx
How do you utilize PM software to manage team activities-SolutionProje.docxHow do you utilize PM software to manage team activities-SolutionProje.docx
How do you utilize PM software to manage team activities-SolutionProje.docx
cliftonl1
 
how do the different architectures of a polymer affect their propertie.docx
how do the different architectures of a polymer affect their propertie.docxhow do the different architectures of a polymer affect their propertie.docx
how do the different architectures of a polymer affect their propertie.docx
cliftonl1
 
How do phospholipid bilayers maintain specific concentrations of solut.docx
How do phospholipid bilayers maintain specific concentrations of solut.docxHow do phospholipid bilayers maintain specific concentrations of solut.docx
How do phospholipid bilayers maintain specific concentrations of solut.docx
cliftonl1
 
how would a police department exhibit different structure and procedur.docx
how would a police department exhibit different structure and procedur.docxhow would a police department exhibit different structure and procedur.docx
how would a police department exhibit different structure and procedur.docx
cliftonl1
 
How will you close your knowledge gap- Is your mind geared to re-think.docx
How will you close your knowledge gap- Is your mind geared to re-think.docxHow will you close your knowledge gap- Is your mind geared to re-think.docx
How will you close your knowledge gap- Is your mind geared to re-think.docx
cliftonl1
 
How to do web application testing on a website checking it-'s (Functio.docx
How to do web application testing on a website checking it-'s (Functio.docxHow to do web application testing on a website checking it-'s (Functio.docx
How to do web application testing on a website checking it-'s (Functio.docx
cliftonl1
 
How to make a Mic 1 L2 instruction set that takes in user input throug.docx
How to make a Mic 1 L2 instruction set that takes in user input throug.docxHow to make a Mic 1 L2 instruction set that takes in user input throug.docx
How to make a Mic 1 L2 instruction set that takes in user input throug.docx
cliftonl1
 

More from cliftonl1 (20)

How many dance steps would the square have-and-Construct a multiplicat.docx
How many dance steps would the square have-and-Construct a multiplicat.docxHow many dance steps would the square have-and-Construct a multiplicat.docx
How many dance steps would the square have-and-Construct a multiplicat.docx
 
How has the physician-patient relationship changed over the past centu.docx
How has the physician-patient relationship changed over the past centu.docxHow has the physician-patient relationship changed over the past centu.docx
How has the physician-patient relationship changed over the past centu.docx
 
How is treasury stock shown on the balance sheet- Treasury stock is no.docx
How is treasury stock shown on the balance sheet- Treasury stock is no.docxHow is treasury stock shown on the balance sheet- Treasury stock is no.docx
How is treasury stock shown on the balance sheet- Treasury stock is no.docx
 
How is repetition of components different from redundancy- How are the.docx
How is repetition of components different from redundancy- How are the.docxHow is repetition of components different from redundancy- How are the.docx
How is repetition of components different from redundancy- How are the.docx
 
How is communication a part of best practices-Solution4 Leadership Bes.docx
How is communication a part of best practices-Solution4 Leadership Bes.docxHow is communication a part of best practices-Solution4 Leadership Bes.docx
How is communication a part of best practices-Solution4 Leadership Bes.docx
 
How does the National Society of Professional Engineers Code of Ethics.docx
How does the National Society of Professional Engineers Code of Ethics.docxHow does the National Society of Professional Engineers Code of Ethics.docx
How does the National Society of Professional Engineers Code of Ethics.docx
 
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docxhow does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
how does cinchona catalyst workSolutionCatalyst working- 1) Catalyst i.docx
 
How does the evolution of attack tools affect existing systems- What s.docx
How does the evolution of attack tools affect existing systems- What s.docxHow does the evolution of attack tools affect existing systems- What s.docx
How does the evolution of attack tools affect existing systems- What s.docx
 
How do you think the DATA Act will impact governmental entities and st.docx
How do you think the DATA Act will impact governmental entities and st.docxHow do you think the DATA Act will impact governmental entities and st.docx
How do you think the DATA Act will impact governmental entities and st.docx
 
How do I determine the Rf Value with just the information I have provi.docx
How do I determine the Rf Value with just the information I have provi.docxHow do I determine the Rf Value with just the information I have provi.docx
How do I determine the Rf Value with just the information I have provi.docx
 
How do I print a list of payroll checks for the calendar year to date.docx
How do I print a list of payroll checks for the calendar year to date.docxHow do I print a list of payroll checks for the calendar year to date.docx
How do I print a list of payroll checks for the calendar year to date.docx
 
How does SO2 in the atmosphere affect global warming- In general- what.docx
How does SO2 in the atmosphere affect global warming- In general- what.docxHow does SO2 in the atmosphere affect global warming- In general- what.docx
How does SO2 in the atmosphere affect global warming- In general- what.docx
 
How does an awareness of the historical link between the United States.docx
How does an awareness of the historical link between the United States.docxHow does an awareness of the historical link between the United States.docx
How does an awareness of the historical link between the United States.docx
 
How do you utilize PM software to manage team activities-SolutionProje.docx
How do you utilize PM software to manage team activities-SolutionProje.docxHow do you utilize PM software to manage team activities-SolutionProje.docx
How do you utilize PM software to manage team activities-SolutionProje.docx
 
how do the different architectures of a polymer affect their propertie.docx
how do the different architectures of a polymer affect their propertie.docxhow do the different architectures of a polymer affect their propertie.docx
how do the different architectures of a polymer affect their propertie.docx
 
How do phospholipid bilayers maintain specific concentrations of solut.docx
How do phospholipid bilayers maintain specific concentrations of solut.docxHow do phospholipid bilayers maintain specific concentrations of solut.docx
How do phospholipid bilayers maintain specific concentrations of solut.docx
 
how would a police department exhibit different structure and procedur.docx
how would a police department exhibit different structure and procedur.docxhow would a police department exhibit different structure and procedur.docx
how would a police department exhibit different structure and procedur.docx
 
How will you close your knowledge gap- Is your mind geared to re-think.docx
How will you close your knowledge gap- Is your mind geared to re-think.docxHow will you close your knowledge gap- Is your mind geared to re-think.docx
How will you close your knowledge gap- Is your mind geared to re-think.docx
 
How to do web application testing on a website checking it-'s (Functio.docx
How to do web application testing on a website checking it-'s (Functio.docxHow to do web application testing on a website checking it-'s (Functio.docx
How to do web application testing on a website checking it-'s (Functio.docx
 
How to make a Mic 1 L2 instruction set that takes in user input throug.docx
How to make a Mic 1 L2 instruction set that takes in user input throug.docxHow to make a Mic 1 L2 instruction set that takes in user input throug.docx
How to make a Mic 1 L2 instruction set that takes in user input throug.docx
 

Recently uploaded

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
Vivekanand Anglo Vedic Academy
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
parmarsneha2
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
ricssacare
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
Sayali Powar
 

Recently uploaded (20)

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
plant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated cropsplant breeding methods in asexually or clonally propagated crops
plant breeding methods in asexually or clonally propagated crops
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 

How do I transfer this m-file to make it into a Function m-file in MAT.docx

  • 1. How do I transfer this m-file to make it into a Function m-file in MATLAB? This is the only thing i have left before i turn in my project, if you can help me clear this up i would appreciate it. clear all; a=input('Enter any desired row vector in []:'); n=length(a); for ii=1:n fprintf('ii = %d ', ii); for jj = 1:n fprintf(' jj = %d ', jj); for kk=1:n fprintf(' kk = %d ', kk); A(ii,jj)= a(ii)*a(jj)*a(kk); end end end A plot(A) I keep getting these errors: Line 1: Invalid syntax at 'Enter any desired row vector in []:'. Possibly, a ), } , or ] is missing. Line 1: Parse error at ')' : usage might be invalid MATLAB syntax ! Line 1: The function return value 'a' might be unset. Solution ANSWER: To convert a piece of code into a function to which parameters can be passed the folowing is the syntax to be used. function func_name(variable) where func_name is the name of the function we intend to keep and variable is the variable to be passed to the function.
  • 2. function assignment(a) clear all; n=length(a); for ii=1:n fprintf('ii = %d ', ii); for jj = 1:n fprintf(' jj = %d ', jj); for kk=1:n fprintf(' kk = %d ', kk); A(ii,jj)= a(ii)*a(jj)*a(kk); end end end plot(A); The above change has to be incorporated.