Why does the following function produce error (Index in position 2 exceeds array bounds)?

조회 수: 1 (최근 30일)
Why does the following function produce error-
Index in position 2 exceeds array bounds.
Error in POD_DMD (line 47)
imagesc(reshape(Phi(1:r*c,mode),r,c));axis
image;set(gca,'Ydir','Normal')
close all
figure('name','POD')
subplot(figs,1,1)
imagesc(reshape(Phi(1:r*c,mode),r,c));axis image;set(gca,'Ydir','Normal')
title(['\Phi',sprintf('_%i (u-component)',mode)])
subplot(figs,1,2-d)
if com == 2
imagesc(reshape(Phi(r*c+1:end,mode),r,c));axis image;set(gca,'Ydir','Normal')
title(['\Phi',sprintf('_%i (v-component)',mode)]);
end
Please suggest possible solution.
Thanks!
  댓글 수: 10
Priyank Goel
Priyank Goel 2021년 7월 12일
Dear Walter,
I was able to read directory
K>> ls(directory)
. scene_0016.bmp scene_0033.bmp scene_0050.bmp
.. scene_0017.bmp scene_0034.bmp scene_0051.bmp
scene_0001.bmp scene_0018.bmp scene_0035.bmp scene_0052.bmp
scene_0002.bmp scene_0019.bmp scene_0036.bmp scene_0053.bmp
scene_0003.bmp scene_0020.bmp scene_0037.bmp scene_0054.bmp
scene_0004.bmp scene_0021.bmp scene_0038.bmp scene_0055.bmp
scene_0005.bmp scene_0022.bmp scene_0039.bmp scene_0056.bmp
scene_0006.bmp scene_0023.bmp scene_0040.bmp scene_0057.bmp
scene_0007.bmp scene_0024.bmp scene_0041.bmp scene_0058.bmp
scene_0008.bmp scene_0025.bmp scene_0042.bmp scene_0059.bmp
scene_0009.bmp scene_0026.bmp scene_0043.bmp scene_0060.bmp
scene_0010.bmp scene_0027.bmp scene_0044.bmp scene_0061.bmp
scene_0011.bmp scene_0028.bmp scene_0045.bmp scene_0062.bmp
scene_0012.bmp scene_0029.bmp scene_0046.bmp
scene_0013.bmp scene_0030.bmp scene_0047.bmp
scene_0014.bmp scene_0031.bmp scene_0048.bmp
scene_0015.bmp scene_0032.bmp scene_0049.bmp
But now the issue is: Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side.
Error in POD_DMD (line 17)
data(:,:,count) =
imread(sprintf('%s/scene_%04d.bmp',directory,count));
Please help as I am not experienced in Matlab.
Walter Roberson
Walter Roberson 2021년 7월 12일
data(:,:,count) =
rgb2gray(imread(sprintf('%s/scene_%04d.bmp',directory,count))) ;

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

답변 (1개)

Priyank Goel
Priyank Goel 2021년 7월 12일
편집: Priyank Goel 2021년 7월 12일
Thanks a lot Walter, now I am able to run it.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by