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일

0 개 추천

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개)

카테고리

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

제품

릴리스

R2020a

태그

질문:

2020년 4월 26일

댓글:

2020년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by