creating and modifying a cell array

Hello I have a cell array of data R
R = cell 1: 4 6 8
cell 2: 5 9 12
cell 3: 6 13 14
I want to create another cell array X that is the X = f( R ) which the same length
X = cell 1: X1 X2 X3
cell 2: X4 X5 X6
cell 3: X7 X8 X9
Next I want to subtract a vector Z [1x3] from every term in the cell array X
so Y would look like this
Y = cell 1: X1-Z1, X2-Z1, X3-Z1
cell 2: X4-Z2, X5-Z2, X6-Z2
cell 3: X7-Z3, X8-Z3, X9-Z3
Thanks!

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 2 月 12 日
編集済み: Azzi Abdelmalek 2015 年 2 月 12 日

0 投票

Use cellfun
X=cellfun(@sin,R)

3 件のコメント

shobhit mehrotra
shobhit mehrotra 2015 年 2 月 12 日
what if instead of sin, i want to run through a function I created? which isn't a standard matlab function.
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 2 月 12 日
X=cellfun(@yourfun,R)
shobhit mehrotra
shobhit mehrotra 2015 年 2 月 12 日
Its not working, say R are indices and X is the value of the function at those indices, when i try to use the function is saying
co2i" was previously used as a variable, conflicting with its use here as the name of a function or command.

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

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

製品

質問済み:

2015 年 2 月 12 日

コメント済み:

2015 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by