Using Log in Matlab
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Something strange seems to be happening in Matlab and i dont understand why
if im calculating a matrix called M, using actual numbers lets call them A,B and reading from another matrix say M2;
M = 5*log10(A) - B + M2;
i should if i set A to be 1000 get 3 minus two numbers right? but i dont, however i do get the expected answer if i hard code the number A in at 1000 just not with the variable, what is the reason for this? im guessing it involves the matrix M2 or something?
0 comentarios
Respuestas (2)
Thomas
el 26 de Nov. de 2012
I get the correct result both times
A=1000;
B=3;
M2=[1 2;3 4]
M=5*log10(A)-B+M2
M =
13.00 14.00
15.00 16.00
Now by hard coding the values
M=5*log10(1000)-3+[1 2;3 4]
M =
13.00 14.00
15.00 16.00
0 comentarios
Wayne King
el 26 de Nov. de 2012
Editada: Wayne King
el 26 de Nov. de 2012
Can you be more specific with a simple example, you won't get 3, you'll get 15 since you are doing
5*log10(A)
So if A = 1000, the 5*log10(A) is 15. You get 15 - the sum of the two matrices B and M2
B = ones(5,5);
M2 = 2*ones(5,5);
A = 1000;
M = 5*log10(A) - B + M2;
So for the above you get 15- a matrix of ones, that gives you a matrix of 14's. And then you add a matrix of 2's so you get a matrix of 16's.
Not that is different than
M = 5*log10(A) - (B + M2);
In the above you first add the matrix of ones to the matrix of 2's and then subtract that matrix of 3's from 15 to get a matrix of 12's.
0 comentarios
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!