필터 지우기
필터 지우기

Difference between {} and []

조회 수: 480 (최근 30일)
alpedhuez
alpedhuez 2018년 4월 29일
답변: Image Analyst 2018년 4월 30일
What is the difference between
A = {0,1,2}
and
A = [0,1,2]
?
  댓글 수: 3
John D'Errico
John D'Errico 2018년 4월 29일
편집: John D'Errico 2018년 4월 29일
help parens
does give a nice explanation. I was actually surprised that
doc parens
finds nothing at all. A further check shows that I had to do
doc paren
in order for it to give me help. That seems a bit silly, because when I did help on parens, it told me that it could not find parens, so it gave me the help for paren. Why was doc not as smart as help? (Probable answer: because they were written by different people, to subtly different specs.)
dpb
dpb 2018년 4월 29일
편집: dpb 2018년 4월 29일
What's more is that
help paren
help parens
both return the same help page.
I'm of the age and began using Matlab when all you had from the opening command line was 'help' and I still recommend for all newcomers that is really still a very good exercise to go through of just skimming the various categories; that overview is invaluable to get a feeling for what facilities are available in what areas very quickly; far more than trying to dig through the doc.
One does have to use
>> help
HELP topics:
Documents\MATLAB - (No table of contents file)
matlab\datafun - Data analysis and Fourier transforms.
matlab\datatypes - Data types and structures.
matlab\elfun - Elementary math functions.
matlab\elmat - Elementary matrices and matrix manipulation.
matlab\funfun - Function functions and ODE solvers.
matlab\general - General purpose commands.
matlab\iofun - File input and output.
matlab\lang - Programming language constructs.
matlab\matfun - Matrix functions - numerical linear algebra.
matlab\ops - Operators and special characters.
matlab\polyfun - Interpolation and polynomials.
matlab\randfun - Random matrices and random streams.
matlab\sparfun - Sparse matrices.
matlab\specfun - Specialized math functions.
matlab\strfun - Character arrays and strings.
matlab\timefun - Time and dates.
...
>> help ops
to get to paren under the 'Special Characters' section.
But, if in parallel to
>> help
one tries
>> doc
you get the welcome page and no way afaict to get an equivalent list of links to the content as organized in help files; while the
>> doc paren
opens the help files in the html view but from
>> doc
all searches are restricted to within the doc files; the help files aren't indexed so there's no getting across the great divide from that direction while from the Help view there's a link Topics that opens the main doc window; once there there's backtrack; you have to close that window and return to the one left to get back to the help file viewer.

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

답변 (2개)

Alfonso
Alfonso 2018년 4월 29일
편집: Alfonso 2018년 4월 29일
A = {0,1,2} constructs an array of class cell, basically this type of class can contain any type of data. For further information ( https://es.mathworks.com/help/matlab/cell-arrays.html )
A = [0,1,2] uses the matrix constructor operator, which in your case will construct you a three element-vector of class double or a one row matrix of three elements of class double, which is the same. For further information you can take a look here ( https://es.mathworks.com/help/matlab/math/creating-and-concatenating-matrices.html )

Image Analyst
Image Analyst 2018년 4월 30일

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by