필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by