Matlab for循环显示错误下标的赋值维度不匹配

Matlab for循环显示错误下标的赋值维度不匹配,matlab,loops,for-loop,dimension,mismatch,Matlab,Loops,For Loop,Dimension,Mismatch,嗨,有人能告诉我为什么我不能得到第十次迭代的输出,以及如何在这个循环中解决这个问题吗 i=10; for ix=1:i V='.jpg'; ie=num2str(ix); Stc(:,:)=strcat(ie,V); St=imread(Stc); u=St; figure(1),subplot(4,4,ix),imshow(St); title('original image'); Nd(ix)=ndims(St);

嗨,有人能告诉我为什么我不能得到第十次迭代的输出,以及如何在这个循环中解决这个问题吗

i=10; 

for ix=1:i
    V='.jpg';
    ie=num2str(ix);
    Stc(:,:)=strcat(ie,V);
    St=imread(Stc);
    u=St;
    figure(1),subplot(4,4,ix),imshow(St);
    title('original image');
    Nd(ix)=ndims(St);
    if Nd>2
        St=rgb2gray(St);
    end
end
我得到的错误如下:

下标赋值维度不匹配。 主线错误(第12行) Stc(:,:)=strcat(即,V)


有人告诉我获取输出的解决方案吗?问题是从1到9,
Stc
中的列数是5,其中有'1.jpg','2.jpg'…'9.jpg。但是在下一次迭代中,字符串长度随着'10.jpg'而变为6,因此不能适应
Stc
。我建议您对代码进行以下更改,只需删除或注释掉
Stc
行即可-

St=imread(strcat(ie,V));