How to represent set?

9 次查看(过去 30 天)
Newbie here try to implement an algorithm in MATLAB but do not know how to represent set.
For example, when initiate the algorithm, i need to:
Set .
And .
I tried this
C{0} = [] % Error: Array indices must be positive integers or logical values.
C{1} = 1:N
I am not sure how to set empty set and if I am doing right with C_1.
Can anyone help me?
Thanks!

采纳的回答

Ameer Hamza
Ameer Hamza 2020-4-26
In MATLAB, the index starts from 1. So the first line should be
C{1} = [];
The variable should also be defined before its use. So you need to specify define
N = 10;
C{2} = 1:N;
  2 个评论
2020noOlympics
2020noOlympics 2020-4-26
Thanks for reply so soon! I forgot that index starts from 1.
Ameer Hamza
Ameer Hamza 2020-4-26
I am glad to be of help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by