Run every element through a function and return a new array

1 回表示 (過去 30 日間)
Adam Kepinski
Adam Kepinski 2017 年 11 月 16 日
回答済み: Andrei Bobrov 2017 年 11 月 16 日
Hi, I have a 1000x1 table and I want to run every row through a function y=a*x+b-1 where a and be are constants, and x are the elements from the table. The result should be a new 1000x1 table. Can anybody help?
Cheers.

採用された回答

Adam
Adam 2017 年 11 月 16 日
doc rowfun
using
func = @(x) a*x + b - 1;
should work for this provided a and b are already defined at the point you include the definition of func.

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2017 年 11 月 16 日
a = 3;
b = 4;
T_out = rowfun(@(x)a*x+b-1,T,'OutputV','data');

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by