Conversion to cell from double is not possible.

clc
close all
n = input("enter the basis matrix dimension: ");
alpha2 = ones(1,n)*sqrt(2/n);
alpha2(1) = sqrt(1/n);
alpha1 = ones(1,n)*sqrt(2/n);
alpha(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
mag = a;
figure();
k=1;
for i = 1:n
for j = 1:n
subplot(n,n,k)
imshow(mag{i,j})
k = k+1;
end
end
Conversion to cell from double is not possible.
Error in dctma (line 13)
a {u+1,v+1}(x+1,y+1) = alpha1(u+1)*alpha2(v+1)*...

댓글 수: 4

Jonas
Jonas 2022년 7월 14일
i dont have problems running this code. what was your input as n?
Divya
Divya 2022년 7월 14일
i am enterring 2 or 4, but error is same.
Rogan
Rogan 2024년 1월 6일
how to make it so simplier
@Rogan How to make what so simpler?

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

 채택된 답변

Jan
Jan 2022년 7월 14일

0 개 추천

If a variable is not defined before, the default type is double . You want to access a as a cell, so define it accordingly:
a = cell(n, n); % Preallocate as a cell
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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Elementary Math에 대해 자세히 알아보기

질문:

2022년 7월 14일

댓글:

2024년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by