use function with user defined variable in GA
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2021년 9월 6일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!