Run every element through a function and return a new array
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adam Kepinski
am 16 Nov. 2017
Beantwortet: Andrei Bobrov
am 16 Nov. 2017
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.
0 Kommentare
Akzeptierte Antwort
Adam
am 16 Nov. 2017
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.
0 Kommentare
Weitere Antworten (1)
Andrei Bobrov
am 16 Nov. 2017
a = 3;
b = 4;
T_out = rowfun(@(x)a*x+b-1,T,'OutputV','data');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!