Covert vector into an image using matlab?

I am trying to convert vector into an image using the code below
clear variables
load(Exe4_2022.mat')
n = length(b);
figure,
imagesc(reshape(b,sqrt(n),sqrt(n))),
colormap(gray),
axis off;
But I am getting this error. Could anybody tells me how to resolve this issue??
Error using reshape
Size arguments must be real integers.
I have attached the "Exe4_2022.mat" file with this post.
Thanks

Réponses (1)

Matt J
Matt J le 4 Déc 2022
Modifié(e) : Matt J le 4 Déc 2022

0 votes

n is not a perfect square, so sqrt(n) will not give you valid integer dimensions for your image. Choose different dimensions.

Catégories

En savoir plus sur Images dans Centre d'aide et File Exchange

Question posée :

le 4 Déc 2022

Modifié(e) :

le 4 Déc 2022

Community Treasure Hunt

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

Start Hunting!

Translated by