Matrix dimensions must agree.
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Soong Wei Kang
el 9 de Jul. de 2020
Comentada: madhan ravi
el 9 de Jul. de 2020
I keep getting the error message : Matrix dimensions must agree. from the code "A = abs(imgA).*exp(1*(1i*rando*pi)); " May i know what is the solution for this?
%% Mesh
close all
n=145; % Number of pixels on one axis
rmax=1; % Normalized radius
X=2*rmax*(-n/2+0.5:1:n/2-0.5)/n; % range for grid (from R=0 to R=1)
Y=2*rmax*(-n/2+0.5:1:n/2-0.5)/n; % range for grid (from R=0 to R=1)
[xm,ym]=meshgrid(X,Y); % x-y coordinates for range of grid
R= sqrt(xm.^2 + ym.^2); % Normalized radius vector
rando=randn(145,145); % random phase initialization
imgA = imread('void.jpg');
imgB = imread('void2.jpg');
%Convert source image to Grayscale
imgA = rgb2gray(imgA);
imgB = rgb2gray(imgB);
figure; imshow(imgA); title('Grayscale ImageA');
figure; imshow(imgB); title('Grayscale ImageB');
%Get the size of the source image
[rowsSource, colsSource, numberOfColorChannelsSource] = size(imgA);
%Get the size of image B
[rowsTarget, colsTarget, numberOfColorChannelsTarget] = size(imgB);
%Check if lateral sizes match
if rowsimgB ~= rowsimgA || colsimgA ~= colsimgB
imgB = imresize(imgB, [rowsimgA colsimgA]);
end
%Convert images to double
imgA = im2double(imgA);
imgB = im2double(imgB);
%% Source plane to target plane
A = abs(imgA).*exp(1*(1i*rando*pi)); % source amplitude (captured on camera) with random source phase = reconstructed source mode
A=A./max(max(A));
0 comentarios
Respuesta aceptada
madhan ravi
el 9 de Jul. de 2020
Editada: madhan ravi
el 9 de Jul. de 2020
rando = randn(size(imgA)); % random phase initialization, put this line after imgA = ...
size(imgA) should be be equal to size(rando) to be compatible with matrix or array vs matrix multiplication
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!