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

Walter Roberson
Walter Roberson 2019년 10월 25일
? 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
Zeynab Mousavikhamene 2019년 10월 26일
no they are not zero if they were zero I would recieve
table.A= 0
0
0
...
not A= 0×1 empty double column vector
Yes all of columns are numeric.
The table has 8 rows which are empty now and I want to make them zero instead of "empty"
Guillaume
Guillaume 2019년 10월 26일
편집: Guillaume 2019년 10월 26일
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
Zeynab Mousavikhamene 2019년 10월 26일
편집: Zeynab Mousavikhamene 2019년 10월 26일
Look at the table attached table:
You are right one of the dimensions are zero.
Guillaume
Guillaume 2019년 10월 26일
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 2019년 10월 26일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Peter Perkins
Peter Perkins 2019년 10월 30일

0 개 추천

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

Walter Roberson
Walter Roberson 2019년 10월 30일
I think the missing part is an if isempty test, which the user seems reluctant to code.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2019년 10월 25일

댓글:

2019년 10월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by