Effacer les filtres
Effacer les filtres

Unexplicable "Operands to the logical AND .." error from "histogram" command

1 vue (au cours des 30 derniers jours)
z8080
z8080 le 25 Fév 2024
Commenté : z8080 le 25 Fév 2024
I have a script written on a computer using Matlab 2023a, which runs without problems. I ran that script on another PC, with a new installation of Matlab 2023a (preference folder copied from the old PC). The script seems to stumble with the histogram command, always throwing the error
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values.
Error in histogram (line 63)
if nargin == 3 && ishandle(varargin{end}) && varargin{end} ~= 0
Without detailing the data structures of said script, a minimal running example is the one found in the Matlab documentation example:
x = randn(1000,1)
h = histogram(x,'Normalization','probability')
which gives the same error as above.
To recap, Matlab versions, settings, file paths, and script contents, are all identical between the two PCs, yet this histogram error Is only thrown on the newer PC. Any ideas?

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Fév 2024
In R2023a, the first line of histogram.m that is not a comment, is line 134; you are getting the error on line 64.
You have some third-party histogram function that is interfering.
which -all histogram
  1 commentaire
z8080
z8080 le 25 Fév 2024
Indeed, that was it, there was a rogue histogram function elsewhere in my path!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by