How to calculate Matrix A?! (Fitting or ...)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I need to calculate Matrix A, as you can see in the photo I have attached. (my system is a lot bigger, I simplified it in several rows and columns so it can be understood easily)
I know it can be done by Fitting, however, I do not know how I can define matrix A for this purpose. In Fitting, we can define xdata=F2 and ydata=F1; but what about A?!
If also, you know any other method to calculate A, please let me know.
Thanks, Peyman
2 comentarios
Danilo NASCIMENTO
el 25 de Feb. de 2014
let me know first, you dont wanna type in the 49 elements of matrix A?
Respuestas (1)
John D'Errico
el 25 de Feb. de 2014
You have a bi-diagonal matrix. One common trick is to use diag to create the main diagonal and then the sub-diagonal matrix, adding the two matrices together. Thus if a_main is a vector of main diagonal entries, and a_sub, the vector of the sub-diagonal entries...
a_main = rand(1,7);
a_sub = rand(1,6);
A = diag(a_main) + diag(a_sub,-1)A =
0.75774 0 0 0 0 0 0
0.27692 0.74313 0 0 0 0 0
0 0.046171 0.39223 0 0 0 0
0 0 0.097132 0.65548 0 0 0
0 0 0 0.82346 0.17119 0 0
0 0 0 0 0.69483 0.70605 0
0 0 0 0 0 0.3171 0.031833
Better is to learn to use sparse matrices, here the appropriate function is spdiags, which will create the complete matrix in one call. The nice thing about a sparse matrix is the storage savings as well as a speed boost for large problems.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!