Hi, I had a problem to put the number into a empty cell.
For example:
%start
shift={}
for xxx=-5:5
%here is the code that I need help
shift=shift+xxx
end
I expect the result will become shift={'-5','-4',...'0',...'4','5'}
Thank you for helping
I had try search the answer but there is none of this kind of question.

 採用された回答

Stephen23
Stephen23 2016 年 6 月 21 日
編集済み: Stephen23 2016 年 6 月 21 日

0 投票

This is MATLAB... why waste time using a loop?
cellstr(strjust(num2str((-5:5).'),'left'))
or
arrayfun(@num2str,-5:5,'UniformOutput',false)
or
strsplit(sprintf('%d,',-5:5),',') % and remove the last cell

2 件のコメント

Marco Yu
Marco Yu 2016 年 6 月 21 日
It is because I am not familiar to the function. So I am trying to use a for loop to put each value into a cell,or a arry
Stephen23
Stephen23 2016 年 6 月 21 日
編集済み: Stephen23 2016 年 6 月 21 日
MATLAB is not a low-level language that needs loops to solve everything... practice reading and navigating the documentation, then you will know how to find functions and use MATLAB efficiently:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2016 年 6 月 21 日

編集済み:

2016 年 6 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by