what is the difference between n={ } and n=[], and what are they?

 채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 5일

0 개 추천

{} is used for cells and [] for arrays (matrix) both can store strings but the arrays can't store strings and numeric values at the same time.
Square Brackets — [ ]
Square brackets are used in array construction and concatenation, and also in declaring and capturing values returned by a function
Curly Braces — { }
Use curly braces to construct or get the contents of cell arrays.

댓글 수: 6

Look for more at Symbol Reference in your matlab documentation.
so if I want to store both date_string and number in a single matrix, I should use the curly braces-{}.
what is the command to copy the content from arrays[] to cells{}?
should i use loop:
for i=1:10
for j=1:10
a{i,j}=b(i,j);
end
end
a = num2mat(b) will do the same thing as your loop.
a is an array matrix <1241x11 double>
But,
>> z = num2mat(a)
??? Undefined function or method 'num2mat' for input arguments of
type 'double'.
>> clear z
>> z = num2mat(a)
??? Undefined function or method 'num2mat' for input arguments of
type 'double'.
Sorry, that should have been num2cell
thank you

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by