Error using .* Matrix dimensions must agree.
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad nur adri nawi
le 27 Déc 2020
Modifié(e) : Image Analyst
le 27 Déc 2020
M = 25;
alpha = (M-1)/2;
n = 0:M-1;
hd = (2/pi)*((sin((pi/2)*(n-alpha)).^2)./(n-alpha));
hd(alpha+1)=0;
w_han = '(hann(M))';
h = hd .* w_han; %%%here is the error
2 commentaires
KALYAN ACHARJYA
le 27 Déc 2020
Modifié(e) : KALYAN ACHARJYA
le 27 Déc 2020
Array multiplication between numeric array and character array??
> whos hd
Name Size Bytes Class Attributes
hd 1x25 200 double
>> whos w_han
Name Size Bytes Class Attributes
w_han 1x9 18 char
Aim?
w_han??
muhammad nur adri nawi
le 27 Déc 2020
Modifié(e) : Image Analyst
le 27 Déc 2020
Réponse acceptée
KALYAN ACHARJYA
le 27 Déc 2020
Modifié(e) : KALYAN ACHARJYA
le 27 Déc 2020
In this case hd is numeric array with size 25
whos hd
Name Size Bytes Class Attributes
hd 1x25 200 double
Whereas w_han is character array with size 9
>> whos w_han
Name Size Bytes Class Attributes
w_han 1x9 18 char
Once you try to multiply between the numeric array and the character array, you supose to get an error as follows
Error using .*
Matrix dimensions must agree.
If somehow you increase the size of w_han to 25, then no error can occur. Are you really looking for that? In such case it get multiplied with ASCII code of respective character, see the example
>> a='m'
a =
'm'
>> b=5;
>> c=b.*a
c =
545
Here b is multiplied with ASCII code of m, which is 109, as
>> 5*109
ans =
545
I just want to mention this point, so that you can get the idea, if somehow an error cannot occur, it can happen in such a case.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!