필터 지우기
필터 지우기

how create cell 1:10 vertical

조회 수: 9 (최근 30일)
aldo
aldo 2023년 11월 12일
편집: John D'Errico 2023년 11월 12일
c={(1:10)'}
c = 1×1 cell array
{10×1 double}
%but is not correct..i want to creare 1x10cell

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 12일
c = (1:10).';
c = num2cell(c)
c = 10×1 cell array
{[ 1]} {[ 2]} {[ 3]} {[ 4]} {[ 5]} {[ 6]} {[ 7]} {[ 8]} {[ 9]} {[10]}
  댓글 수: 3
Dyuman Joshi
Dyuman Joshi 2023년 11월 12일
c = (1:10)
c = 1×10
1 2 3 4 5 6 7 8 9 10
For real numbers, ctranspose, ' is equal to transpose, .'
c.'
ans = 10×1
1 2 3 4 5 6 7 8 9 10
c'
ans = 10×1
1 2 3 4 5 6 7 8 9 10
aldo
aldo 2023년 11월 12일
okkk

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

추가 답변 (1개)

John D'Errico
John D'Errico 2023년 11월 12일
편집: John D'Errico 2023년 11월 12일
There are always many ways to solve a problem. An easy way to create the cell array directly is to do this:
C1 = {1;2;3;4;5;6;7;8;9;10}
C1 = 10×1 cell array
{[ 1]} {[ 2]} {[ 3]} {[ 4]} {[ 5]} {[ 6]} {[ 7]} {[ 8]} {[ 9]} {[10]}
And, yes, that works nicely for a small array, but for a larger one you will want to use another tool. num2cell is a good choice, as suggested already. mat2cell will also work, but not quite as nicely.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by