What does [ ]; do in MATLAB?

조회 수: 29 (최근 30일)
JK
JK 2014년 10월 19일
답변: the cyclist 2014년 10월 19일
Hi, I am looking at some codes. It solves for c at the end,
but it defines c=[]; in the beginning which is like empty matrix.
So what does it do ?

채택된 답변

Image Analyst
Image Analyst 2014년 10월 19일
Usually I see that in cases where it must be something because in a loop you're concatenating something onto c. And if c is not defined yet you'll get an error, but it it's something, anything, even null, it's okay. Something like
c = [];
for k = 1 : 5
c = [c, k];
end
If we didn't define c as null then the c= line inside the for loop would throw an exception the very first time.

추가 답변 (1개)

the cyclist
the cyclist 2014년 10월 19일

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by