why does help ignore my comments?

7 vues (au cours des 30 derniers jours)
Derek Fong
Derek Fong le 22 Avr 2020
Commenté : Walter Roberson le 22 Avr 2020
i am not sure when this change was introduced, but it seems that from Matlab 2019a onward (and maybe before), the "help" function is ignoring information i've provided at the top of my function file.
eg,
function [v,d,z]=eof(u)
% EOF empirical orthogonal functions
% [v,d,z]=eof(u)
% time series components stored as column vectors in u.
% v is the matrix of eigenvectors
% d is a diagonal matrix of eigenvalues
% z is the time series of mode amplitudes, stored as column vectors
and i type >> help eof, i get:
eof is a function.
[v, d, z] = eof(u)
rather than the explanation of the function i've included in the top of the m-file. this has always worked (since version 1) so i am not sure what is happening or if this is a bug...
-Derek
  10 commentaires
dpb
dpb le 22 Avr 2020
Steven, wouldn't those go away on restart though -- unless it's caused by a startup.m file which should be pretty easy to check?
Wonder if his lookfor finds the H1 line?
Walter Roberson
Walter Roberson le 22 Avr 2020
... There appear to be entire classes devoted to processing help information.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 22 Avr 2020
The comments need to be the first thing in the file, not within the body of the function (because there are likely to be tons of those):
% EOF empirical orthogonal functions
% [v,d,z]=eof(u)
% time series components stored as column vectors in u.
% v is the matrix of eigenvectors
% d is a diagonal matrix of eigenvalues
% z is the time series of mode amplitudes, stored as column vectors
function [v,d,z]=eof(u)
  8 commentaires
Derek Fong
Derek Fong le 22 Avr 2020
the only restriction (prior to this) i believe existed is that the help "displayed" stops with the first line without a comment.
dpb
dpb le 22 Avr 2020
Since it also works for scripts, I suppose it simply starts with the first comment line in the file and ignores whether there is/isn't a function statement entirely. Hence it would work with whichever sequence is used; I just had always followed the suggested pattern and never tried anything different with functions.
Coming from Fortran, nothing exists outside a program unit so having comments in a file outside a function is "just wrong!" :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by