use function with user defined variable in GA
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mohammad Kalantar
il 6 Set 2021
Risposto: Star Strider
il 6 Set 2021
HI every one
I have a fuction which do some calculation on a very big matrix (42588x17)
this matrix came from an excel file which was imported by readmatrix
the fuction itself take less than 2 secound to run like this
FileContent=readmatrix("Export.xlsx")
function z=myfun(x,FileContent)
.
.
.
end
but if i include the readmatrix command inside it, it take upto 50 secound
function z=myfun(x)
FileContent=readmatrix("Export.xlsx")
.
.
end
now i want to run GA on this fuction for variable x but how can i do it without running readmatrix on each run
i tried global variable but it dosent work for me
0 Commenti
Risposta accettata
Star Strider
il 6 Set 2021
I have no idea what the fitness funciton does, however if it uses data from the Excel file, read the file once and then pass the necessary variables to the fitness function as extra parameters. See the documentation on Passing Extra Parameters for details.
It is not considered good programming practice to use global variables in any event.
.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!