필터 지우기
필터 지우기

Apply equation to an array of values producing a new data set

조회 수: 62 (최근 30일)
Sophie Stringer
Sophie Stringer 2019년 11월 11일
댓글: Erivelton Gualter 2019년 11월 11일
Hi there,
I have an equation:
e = 0.61121*exp((18.678-i/234.5).*(i./(257.14+i)))
where i are my values in my data set of temperature, ranging from 1 to 122736 values.
I want to apply this equation to all the values in my temperature data set, and produce a new data set of variables (e).
I'm thinking this would be best done in a loop, but I am just unsure of how to link my data set to the loop.
What I have so far is:
for i=1:122736
e = 0.61121*exp((18.678-i/234.5).*(i./(257.14+i)))
end
any help would be much appreciated.
Cheers :D
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 11월 11일
e = 0.61121*exp((18.678-Temperature/234.5).*(Temperature./(257.14+Temperature)));
where Temperature is your 1 x 122736 vector of temperature values.

댓글을 달려면 로그인하십시오.

답변 (1개)

Erivelton Gualter
Erivelton Gualter 2019년 11월 11일
You do not need a door loop. Matlab is built to handle this kind of operation. Check the following:
T = 1:1:122736;
FcnT = 0.61121*exp((18.678-T/234.5).*(T./(257.14+T)));
  댓글 수: 2
Sophie Stringer
Sophie Stringer 2019년 11월 11일
Hi Erivelton,
Does this still work if my T values are of the following (attached), with values ranging from 1-122736? Sorry if I was unclear.
Erivelton Gualter
Erivelton Gualter 2019년 11월 11일
It does.
You might check the follolowing page with a few examples of array multiplication: https://www.mathworks.com/help/matlab/ref/times.html

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by