n=20;
I want to make a cell from 1 to n
result should be
result={[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20]}

 채택된 답변

Rik
Rik 2019년 3월 11일

0 개 추천

You can do it like this:
n=20;
result=num2cell(1:n);

댓글 수: 3

if I want this result. What should I do?
T={'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20'}
T=cellfun(@num2str,result);
Thanks.
T=cellfun(@num2str,result,'UniformOutput', false);
without 'UniformOutput', false I have an error

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

추가 답변 (0개)

카테고리

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

질문:

NA
2019년 3월 11일

댓글:

NA
2019년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by