Info

此问题已关闭。 请重新打开它进行编辑或回答。

Matrix Dimensions must agree

1 次查看(过去 30 天)
Gaurav Mathur
Gaurav Mathur 2019-7-14
关闭: MATLAB Answer Bot 2021-8-20
I am getting this error at line 25 for the code:
clc
clear all
i=1;
b=int64(nan(848,896));
c=int64(nan(848,896));
for i=1:9999
if i<10
new="0000";
elseif i<100
new="000";
elseif i<1000
new="00";
elseif i<10000
new="0";
end
i2=new + num2str(i);
path='C001H001S00040'+i2 + '.tif';
a=int64(imread(path));
disp(i2)
i=i+1;
b=b+a;
end
for k=10000:15068
i3=num2str(k);
path_new='C001H001S00040'+i3 + '.tif';
a=int64(imread(path_new));
disp(i3)
k=k+1;
c=c+a;
end
b=(b+c)/15068;
b=uint8(b);
imshow(b)
Error:
Error in new_code (line 25)
path_new='C001H001S00040'+i3 + '.tif';

回答(1 个)

dpb
dpb 2019-7-14
The + operator only works for the class string catenation, not character strings.
path_new="C001H001S00040" + i3 + ".tif";
and will still only work if i3 is also of class string.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by