Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

I Keep Getting Error "Matrix dimensions must agree"

1 Ansicht (letzte 30 Tage)
Alexandra Keith
Alexandra Keith am 11 Dez. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I keep getting error like
Error using .*
Matrix dimensions must agree.
How Can I fix it ? Please help me. Any help given will be much appreciated. Here is the line of code
  1 Kommentar
Adam
Adam am 11 Dez. 2019
You can fix it by ensuring the two sides of the multiplication are the same size. It's really that simple! We have no idea what size af is from the code you showed. You can see trivially in your workspace though so if you give all the information it is a lot easier for people to help.

Antworten (1)

Nicolas B.
Nicolas B. am 11 Dez. 2019
If you are using *, than it is a matrix multiplication and the size of your matrices must be compatible.
If you want to multiply element per element, uses .* .
Examples:
a = [1 2 3];
b = [1 2 3; ...
4 5 6; ...
7 8 9];
c = [9 8 7; ...
6 5 4; ...
3 2 1];
a * b % result -> [30 36 42]
a * c % result -> [30 24 18]
a .* b % result -> [1 4 9
% 4 10 18
% 7 16 26] each value of a multiply all values of the same column in b
b .* c % result -> [ 9 16 21
% 24 25 24
% 21 16 9] multiply element per element
  2 Kommentare
Alexandra Keith
Alexandra Keith am 11 Dez. 2019
But I have using .* and still error.
>> a=imread('tul.jpg');
>> lp=butterlp(a,15,1);
>> af=fftshift(fft2(a));
>> aflp=af.*lp;
Nicolas B.
Nicolas B. am 11 Dez. 2019
what are the size of lp and af?

Diese Frage ist geschlossen.

Produkte


Version

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by