Convert empty table to zero

4 vues (au cours des 30 derniers jours)
Zeynab Mousavikhamene
Zeynab Mousavikhamene le 25 Oct 2019
Commenté : Walter Roberson le 30 Oct 2019
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 commentaires
Guillaume
Guillaume le 26 Oct 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
Zeynab Mousavikhamene le 26 Oct 2019
This table is being produced in a loop and I wanted to have zero table when I dont have any data because this table is being used later for other calculations but I changed my strategy and it is solved for now.
Thanks Guillaume for your help.

Connectez-vous pour commenter.

Réponses (1)

Peter Perkins
Peter Perkins le 30 Oct 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 commentaire
Walter Roberson
Walter Roberson le 30 Oct 2019
I think the missing part is an if isempty test, which the user seems reluctant to code.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by