Conversion to cell from double is not possible.

4 ビュー (過去 30 日間)
Divya
Divya 2022 年 7 月 14 日
コメント済み: Dyuman Joshi 2024 年 1 月 6 日
この 質問 は Star Strider さんによってフラグが設定されました
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 件のコメント
Rogan
Rogan 2024 年 1 月 6 日
how to make it so simplier
Dyuman Joshi
Dyuman Joshi 2024 年 1 月 6 日
@Rogan How to make what so simpler?

サインインしてコメントする。

採用された回答

Jan
Jan 2022 年 7 月 14 日
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
  1 件のコメント
Divya
Divya 2022 年 7 月 15 日
Thanku so much, now it is working fine.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by