Matlab Coding Help: Initialize Variables in Pop and Pro

  • Context: MATLAB 
  • Thread starter Thread starter yeongchuan88
  • Start date Start date
  • Tags Tags
    Coding Matlab
Click For Summary

Discussion Overview

The discussion revolves around understanding the MATLAB code line "chromosome = initialize_variables(pop,pro)" and the differences in function definitions in MATLAB, particularly regarding output variable notation.

Discussion Character

  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant asks for clarification on the meaning of the line of code involving the function initialize_variables.
  • Another participant suggests that initialize_variables is likely a user-defined function that takes inputs pop and pro, with chromosome as the output.
  • There are inquiries about the difference between two function definitions: "function f = initialize_variables(N,problem)" and "function [f] = initialize_variables(N,problem)."
  • A later reply states that there is no difference in the context of a single output variable, but notes that multiple output variables would require a different syntax.

Areas of Agreement / Disagreement

Participants generally agree that there is no functional difference between the two forms of the function definition when there is a single output variable. However, the discussion does not resolve the broader implications or contexts of these definitions.

Contextual Notes

The discussion does not address specific assumptions about the user-defined function or the context in which it is used, nor does it clarify the nature of the inputs pop and pro.

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 ·
Replies
4
Views
4K
Replies
6
Views
4K
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K