Using F1 for help, gives help for wrong function

조회 수: 4 (최근 30일)
Scott MacKenzie
Scott MacKenzie 2021년 10월 6일
댓글: Scott MacKenzie 2021년 10월 7일
Consider this code snippet:
plot(x, y1); % 2D line plot
hold on;
plot(x, y2); % 2D line plot
plot(p); % polyshape plot
When I click in the first "plot" above and press F1, a help window appears with the documentation for the 2D line plot function. That's great.
However, when I click in the third instance of "plot" and press F1, the same documentation appears. That's a problem since this function is the polyshape plot function, not the 2D line plot function. Seems to me the MATLAB IDE should have enough context to figure out which documentation to open... or am I missing something here?

답변 (1개)

Steven Lord
Steven Lord 2021년 10월 7일
Does the variable p exist in the workspace when you ask for help? It's not sufficient that the code to create that variable as a polyspace exists in your file. You don't want MATLAB to run your code when you press F1 to determine which overload's documentation to display. [What if hold or the first calls to plot assigned a new value to p, meaning when that line gets executed or won't do what static analysis of the code said it should?]
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 10월 7일
@Steven Lord Thanks for your response. Yes, the variable p exists and it's an instance of polyshape.
I used that code snippet in my question, just as an example, because it's well known that plot is overloaded with about a dozen variations. The issue actually occurred when I was working on some code using wordcloud from the Text Analytics toolbox. I wanted a bit more detail on the function so I clicked on the function and pressed F1. I was reading away when suddenly I realized the documentation was for the wrong function: MATLAB's built-in wordcloud function, which was not used in the script. That's rather annoying. It seems to me the IDE, without running any code, should be able to determine through context which documentation to show when F1 is pressed on a function.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by