Matlab代码中的错误 [英] Error in my matlab code

查看:90
本文介绍了Matlab代码中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一个我在MATLAB中遇到的问题
我的工作是缩小图像,然后回到原始图像.
问题是,当我运行代码时,它是给我的:

I want to ask about a problem that I faced in MATLAB
my work about zoom out an image and then back to original image.
The problem is that when I ran my code it was gave me this :

    ??? Attempted to access I1(1,38); index out of bounds because size(I1)=[45,37].

Error in ==> sh at 23
        I2(i, j)=I1(i,j);


这是我的代码:


and this is my code:

%this is for back to original image
I2= zeros(m,n); 
I2 = im2double(I1);
for i=1:m 
    for j=1:n 
        I2(i, j)=I1(i,j); %The error that show here
        
    end 
end



谢谢您的帮助.



Thank you for your help

推荐答案

dedoooo写道:
dedoooo wrote:

???尝试访问I1(1, 38 ); 索引超出范围,因为size(I1)= [45, 37 ].

??? Attempted to access I1(1,38); index out of bounds because size(I1)=[45,37].


该错误明确表明您正在尝试访问第 38 个元素,但是该数组仅包含 37 元素.所以改变它.

仅供参考


  • 了解有关索引超出范围异常 [ ^ ]
  • 我不知道matlab:-0

  • The error clearly says that you are trying to access 38th element but where the array contains only 37 elements. So change it.

    FYI


    • Read about Index Out of Bound Exception[^]
    • I don''t know matlab :-0

    • 这篇关于Matlab代码中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆