The 17th colum is 24 values, the 1st one : 3 values and 21 zeros, the 2nd: 5 values and 19 zeros; the 3rd: 6 values and 18 zeros... and so on
Replace value in matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'm looking at the orientation of lines generating using linear regression.
I create a matrix that increases after each loop, generating a new columns with a number of data higher than the previous columns (because there is more lines).
My problem is that in the end my matrix is [24*17], however the data in the first colum are only 3 values, and the rest (19 cells) filled with zeros.
I'd like to analyse the matrix, but i can'tget rid of the "filling-zeros".
Does anyone have an idea?
Thanks
N.
3 comentarios
Walter Roberson
el 14 de Mzo. de 2011
Is the matrix the _result_ of linear regression, or is it input being fed into linear regression ? If it is input to linear regression, what would you intend it to mean to the formula -- that the corresponding components are zero ?
Respuesta aceptada
Oleg Komarov
el 16 de Mzo. de 2011
You can obtain:
A = [0 0 143 143 152
0 0 0 0 151
0 0 0 0 143];
regexprep(evalc('A'), '0', ' ')
A =
143 143 152
151
143
But it's a non tractable string array, i.e. what you're trying to do is meaningful only for visualization purposes and privates A of any computational use.
Oleg
5 comentarios
Más respuestas (2)
Paulo Silva
el 14 de Mzo. de 2011
Two options:
1-ignore first column
mat(:,2:end)
2-replace the zeros on the first column
mat(mat(:,1)==0)=inf %replace zeros with inf
you can choose other things besides inf, maybe NaN or a really small value like eps
3-extra option, replace all zeros
mat(mat==0)=inf %again you can choose the value to replace the zeros
0 comentarios
Nicolas
el 16 de Mzo. de 2011
1 comentario
Walter Roberson
el 16 de Mzo. de 2011
It is not possible to have a numeric matrix with empty spaces.
Ver también
Categorías
Más información sobre Matrix Indexing 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!