I can´t get the matrix dimension right
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am doing a work where it asks me to use the variables zred(matrix 82x1) and d18red(82x1) on a frequencie f 1:0.2:20. for each value of f, i have to calculate the value of t truth this equation
t=(1./(4*f*pi))*atan(sum(sin(4*ti*f*pi))/(sum(cos(4*pi*f*ti)));
and ti with i=1,...,m. i think i have to make a matrix that includes zred and d180red (82x2) to solve the equation above after calculating the t i have to calculate p(f) with this equation
p=(((sum(d18ored*sin(2*pi*f*(ti-t)))).^2)/(sum(d18red*sin(2*pi*f*(ti-t)).^2)))+((sum(d18red*cos(2*pi*f*(ti-t)))).^2)/(sum(d18red*cos(2*pi*f*(ti-t).^2)));
my problem is in this last equation because it gives me a error saying inner matrix dimensions must agree.
0 commentaires
Réponses (1)
Ced
le 2 Nov 2015
Modifié(e) : Ced
le 2 Nov 2015
That's a typical matlab error. In your case, you are asking for a matrix multiplication (, /) where in fact you want an element-wise multiplication (., ./). See here in case you are not familiar with these operations: Array vs. Matrix Multiplication
Two examples from your equation:
t and f are 1x96 row vectors
d18red is a 82x1 column vector
so
f*(ti-t)
does not make sense, because you are trying to make a matrix multiplication between two vectors with dimensions (96x1).
e.g.
d18ored*sin(2*pi*f.*(ti-t))
This (note that I changed * to .*) would therefore be a (82x1) vector times a (1x96) vector, which would give you a (82x96) matrix.
etc. etc.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical 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!