reading a workspace value inside a function

조회 수: 4 (최근 30일)
Asliddin Komilov
Asliddin Komilov 2019년 7월 11일
답변: Asliddin Komilov 2019년 8월 19일
I used xlsread in a function. now I have another function that uses this function, and that function is used by a script. So xlsread is used 100 of times uselessly and I am getting 'out of memory' error (this maybe is not the main cause of the error). if I take xlsread into the script, the function cannot read the read variable, even it is in the workspace. How do I make the function to use the variable, without making it input variable of the function?
thanks
  댓글 수: 10
TADA
TADA 2019년 7월 13일
편집: TADA 2019년 7월 13일
Yes, unfortunately, memoize was introduced in 2017a.
Actually you don't need to keep a MemoizedFunction object as a persistent variable. memoize manages its own cache persistence.
Are you reading the same file every time?
Asliddin Komilov
Asliddin Komilov 2019년 7월 14일
편집: Asliddin Komilov 2019년 7월 14일
yes its the same file, it would be best if I could do it inside the script and make other functions use it. I am not willing to put it in function input because there are many variables used by different functions. But it is already good without 'persistent':
Elapsed time is 0.077645 seconds.
Elapsed time is 1.035841 seconds.
Elapsed time is 0.005850 seconds.
Elapsed time is 1.412184 seconds.
Elapsed time is 0.000608 seconds.
Elapsed time is 1.529667 seconds.
Elapsed time is 0.001081 seconds.
Elapsed time is 1.416243 seconds.
Elapsed time is 0.000831 seconds.
Elapsed time is 1.475994 seconds.
thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Asliddin Komilov
Asliddin Komilov 2019년 8월 19일
the solution was the momoizefun, look for details above.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by