필터 지우기
필터 지우기

Error with dynamically created m-files

조회 수: 2 (최근 30일)
Oliver
Oliver 2011년 8월 4일
As part of a function I have written called "make_odf_pos.m" I have a section of code that writes a helper function to a temporary m-file, "tp10e78e1b_3019_4268_b6a7_f9ade665fc01.m", and then calls the helper function later during execution. However when I call "make_odf_pos.m" I get the following error message:
??? Undefined function or method 'tp10e78e1b_3019_4268_b6a7_f9ade665fc01' for input arguments of type 'double'.
Error in ==> make_odf_pos at 78
fsample = tp10e78e1b_3019_4268_b6a7_f9ade665fc01(wsample,tsample,psample,c);
But if I then call "make_odf_pos.m" again it runs fine without the error. It is as if after creating the temporary file, it is having trouble recognizing that it exists or loading it into memory or something until I exit "make_odf_pos.m" and run it a second time. Does anyone know why this would be and how to fix it?
Thank you for your time!
Sincerely, Oliver

채택된 답변

Nirmal Gunaseelan
Nirmal Gunaseelan 2011년 8월 4일
This is because there is no guarantee that there is a refresh of your file path and your new file may or may not be picked up. A forced REHASH before opening the file should fix the issue.
  댓글 수: 1
Oliver
Oliver 2011년 8월 4일
Great! This works like a charm! Thanks.

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

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 8월 4일
This is basically the same question as your previous one. Did Jan's solution solve the problem?
  댓글 수: 2
Oliver
Oliver 2011년 8월 4일
It's a similar issue but a little different. Jan's solution did solve the problem of an m-file whose contents are changing from one call to the next. However, the problem here is that Matlab can't even call the file the first time. Jan's solution of clearing the function from memory to force a reload won't work here because it's not loaded into memory in the first place.
Fangjun Jiang
Fangjun Jiang 2011년 8월 4일
Thank you for clarification. Good to know!

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by