Convert empty table to zero
Ältere Kommentare anzeigen
I produce a table in for loop that in some cases all elemtents of table might be empty. For example table.A= 0×1 empty double column vector.
How can I convert each element of empty table to zeoro?
6 Kommentare
Walter Roberson
am 25 Okt. 2019
? In such a case, all none of them are already zero. How many zeros would you want output ? And are all of your columns numeric?
Zeynab Mousavikhamene
am 26 Okt. 2019
Neither a table nor a matrix can have empty rows and non-empty rows. So already, we're struggling to understand what your data is stored as. Perhaps, it's a structure?
If something is empty, it means it has size 0 in at least one dimension. If you want to make that something non-empty that 0 dimension must be increased. Again, it's unclear from your question what it should be increased to.
Perhaps, showing the code that you use to create the table would help us understand.
Zeynab Mousavikhamene
am 26 Okt. 2019
Bearbeitet: Zeynab Mousavikhamene
am 26 Okt. 2019
Guillaume
am 26 Okt. 2019
So, you have one table with 0 rows and 9 columns. Obviously, it's difficult to fill 0 rows with anything. The table could be expanded to a given number of rows, is that what you want to do? Why?
Zeynab Mousavikhamene
am 26 Okt. 2019
Antworten (1)
Peter Perkins
am 30 Okt. 2019
The answer might be
>> t = table.empty(0,3)
t =
0×3 empty table
>> t{1,:} = 0
t =
1×3 table
Var1 Var2 Var3
____ ____ ____
0 0 0
but the question isn't clear enough to know.
1 Kommentar
Walter Roberson
am 30 Okt. 2019
I think the missing part is an if isempty test, which the user seems reluctant to code.
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
