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

2 ビュー (過去 30 日間)
z8080
z8080 2024 年 2 月 25 日
コメント済み: z8080 2024 年 2 月 25 日
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?

採用された回答

Walter Roberson
Walter Roberson 2024 年 2 月 25 日
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 件のコメント
z8080
z8080 2024 年 2 月 25 日
Indeed, that was it, there was a rogue histogram function elsewhere in my path!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by