Run every element through a function and return a new array

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.

 Accepted Answer

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.

More Answers (1)

Categories

Tags

Asked:

on 16 Nov 2017

Answered:

on 16 Nov 2017

Community Treasure Hunt

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

Start Hunting!