MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar., error in block struct BLOCKPROC encountered an error while evaluating the user-su

3 次查看(过去 30 天)
n = input("enter the basis matrix dimension: ");
a = cell(n, n);
alpha2 = ones(1,n)*sqrt(2/n);
alpha2(1) = sqrt(1/n);
alpha1 = ones(1,n)*sqrt(2/n);
alpha1(1) = sqrt(1/n);
for u = 0:n-1
for v = 0:n-1
for x = 0:n-1
for y = 0:n-1
a {u+1,v+1}(x+1,y+1) = alpha1(u+1)*alpha2(v+1)*...
cos((2*x+1)*pi*u/(2*n))*cos((2*y+1)*pi*v/(2*n));
end
end
end
end
T = a;
disp(T);
for i = 1:n
for j = 1:n
dc = @(block_struct) T{i,j} * block_struct.data * T{i,j}';
B = blockproc(I,[8 8],dc);
end
end
  4 个评论

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2022-7-16
编辑:Walter Roberson 2022-7-16
The message is correct. blockproc is extracting subsets of I, where I is uint8. Your function dc uses the * operator between some double precision data and the uint8 subset of I. However when you use working with uint8 data, you are only permitted to do arithmetic operations if both operands are uint8, or if one of the operands is a scalar double. uint8 combined with matrix of double is not permitted.
What datatype are you expecting the output to be?
Perhaps you need
dc = @(block_struct)
uint8( T{i,j} * double(block_struct.dat) * T{i,j}');

Community Treasure Hunt

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

Start Hunting!

Translated by