Why do I get "Array indices must be positive integers or logical values." error?

Hello!! When I try to run the following code, I get this error "Array indices must be positive integers or logical values." and I don't understand why.
img=imread('Barbara.bmp'); colormap(gray(256));
image(img); axis off; truesize;
S=2;img2=img(1:S:end,1:S:end);
figure; colormap(gray(256));
image(img2); axis off; truesize;
The error comes from line 1. Do I have to install anything to make it work?

댓글 수: 2

@Ali Marie Avila Wragg: please show us the complete error message. This means all of the red text.
Array indices must be positive integers or logical values.
Error in Apartado3 (line 1)
img=imread('Barbara.bmp'); colormap(gray(256));

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 11월 5일
You probably have a variable named colormap that is interfering with using the function colormap

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2020년 11월 5일

댓글:

2023년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by