Fixunknowns function resulting logical rows
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Randi Pratama
il 16 Ago 2018
Modificato: Randi Pratama
il 16 Ago 2018
Hello everyone,
Say Num is matrix with these numbers,
1 2 NaN 3
4 5 NaN NaN
NaN 3 2 3
And if fixunknowns used on Num, it will result like this,
1.0000 2.0000 2.0000 3.0000
1.0000 1.0000 0 1.0000
4.0000 5.0000 4.5000 4.5000
1.0000 1.0000 0 0
2.6667 3.0000 2.0000 3.0000
0 1.0000 1.0000 1.0000
Is there any way to get rid those 1 and 0 (logical) rows? If so please kindly answer this question, or guide me to the documentation if it's available.
Thank you,
Randi
0 Commenti
Risposta accettata
Stephen23
il 16 Ago 2018
Modificato: Stephen23
il 16 Ago 2018
Where M is the output matrix:
new = M(1:2:end,:)
4 Commenti
Stephen23
il 16 Ago 2018
Modificato: Stephen23
il 16 Ago 2018
"Just a little bit curious, how is it works?"
The fixunknowns help clearly describes the output matrix: you only want every second row. This is easy to do with indexing (as my answer shows). Using indexing is one of the most basic MATLAB operations, as shown in the introductory tutorials:
And in more detail here:
The indexing in my answer simply uses the colon operator to generate a row index selecting every second row, starting from the first row, and going until the end row. The colon for the column index means "all columns" of the matrix.
"I've tried a bigger matrix with inf number on it and it doesn't work"
Indexing works for all MATLAB arrays, regardless of their size. I have no idea what code you tried, how you used Inf, or what "it doesn't work" means. If you want help please show the code you tried and explain what you expected.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Function Approximation and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!