Using F1 for help, gives help for wrong function

3 views (last 30 days)
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?

Answers (1)

Steven Lord
Steven Lord on 7 Oct 2021
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 Comment
Scott MacKenzie
Scott MacKenzie on 7 Oct 2021
@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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!