필터 지우기
필터 지우기

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

조회 수: 1 (최근 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 CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by