Hi,
is there another notation than - for example - num2cell(50:50:200)? I question because {50:50:200} would create a cell - so i thougth that there is -maybe- a simpler notation for getting a cell-array, without using a function..
Thanks and greetings

 채택된 답변

Star Strider
Star Strider 2016년 11월 20일

0 개 추천

The results of the two operations are different:
C1 = num2cell(50:50:200)
C2 = {50:50:200}
C1 =
1×4 cell array
[50.0000e+000] [100.0000e+000] [150.0000e+000] [200.0000e+000]
C2 =
cell
[1×4 double]
So what you use to create the cell array depends on what you want it to be.

댓글 수: 5

Udo Kessler
Udo Kessler 2016년 11월 20일
Yes, my question is, if there is a simpler notaion for your C1 (creating a cell-array) than using the function num2cell?
Image Analyst
Image Analyst 2016년 11월 20일
Adding ten characters "num2cell()" to your code is too complicated? Come on! I doubt any alternative solution would add fewer characters than that.
Star Strider
Star Strider 2016년 11월 20일
@Udo Kessler — Not to my knowledge. See: Cell Arrays.
@Image Analyst — My sentiments exactly!
Udo Kessler
Udo Kessler 2016년 11월 20일
:-) It was just a question coming to my mind while learnig Matlab. There are so many possible notations for so many things..
Star Strider
Star Strider 2016년 11월 20일
No worries!
That is the reason I directed you to the documentation for cell arrays. There are in general several ways to do most things in MATLAB, so what is ‘best’ depends upon the context.

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

추가 답변 (0개)

카테고리

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

질문:

2016년 11월 20일

댓글:

2016년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by