MATLAB Matlab Coding Help: Initialize Variables in Pop and Pro

  • Thread starter Thread starter yeongchuan88
  • Start date Start date
  • Tags Tags
    Coding Matlab
AI Thread Summary
The line "chromosome = initialize_variables(pop, pro);" indicates that "initialize_variables" is likely a user-defined function in MATLAB that takes "pop" and "pro" as inputs and returns "chromosome" as the output. To understand this function better, users are advised to type "help initialize_variables" in the MATLAB command prompt. There is no functional difference between defining a function as "function f = initialize_variables(N, problem)" and "function [f] = initialize_variables(N, problem)" when there is a single output variable. However, if multiple outputs are defined, such as "function [f, g] = initialize_variables(N, problem)," the brackets become necessary. The discussion clarifies that for single outputs, the use of brackets is optional.
yeongchuan88
Messages
4
Reaction score
0
chromosome = initialize_variables(pop,pro);


What is the meaning of this line ?

Thank you..
 
Physics news on Phys.org
Hi
initialize_variables could be a user defined function which takes pop and pro as inputs and chromosome is the output of the function.
Type "help initialize_variables" in MATLAB command prompt to know about that function.
 
What is the difference betweenfunction f = initialize_variables(N,problem)

and

function [f] = initialize_variables(N,problem)Thank you !
 
Last edited:
yeongchuan88 said:
What is the difference between


function f = initialize_variables(N,problem)

and

function [f] = initialize_variables(N,problem)


Thank you !

No difference.
If two output variables are there (say f and g)then
function [f,g] = initialize_variables(N,problem)

For single variable it won't make difference.
 

Similar threads

Replies
4
Views
4K
Replies
5
Views
3K
Replies
5
Views
2K
Replies
4
Views
1K
Replies
8
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
Back
Top