Get data from each row as inputs to a function

Hi everyone, I have a function f(a,b,c,x,y) where a,b,c are fixed and I have to get x,y from a table of data. I'm thinking of creating columns with all a's, b's and c's and then apply the function. Is this a good idea? Is there anyway I can loop through each row and compute the function for that row instead?

댓글 수: 3

Wan Ji
Wan Ji 2021년 12월 22일
Please show more details about your function and input variables
KSSV
KSSV 2021년 12월 22일
Show us the function f. Mostly you may need not to run a loop.
The function is
Volatility = impvbybjs(RateSpec,StockSpec,Settle,Maturity,OptSpec,Strike,OptPrice)
from MATLAB financial toolbox. My data has 93 rows of different Strikes and OptPrices. Thanks!

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

답변 (1개)

Stephen23
Stephen23 2021년 12월 22일

0 개 추천

N = numel(Strike);
Volatility = cell(1,N);
for k = 1:N
Volatility{k} = impvbybjs(RateSpec,StockSpec,Settle,Maturity,OptSpec,Strike(k),OptPrice(k));
end

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

태그

질문:

2021년 12월 22일

답변:

2021년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by