Function is not running. please help me.

2 次查看(过去 30 天)
I have a program (attached) namely singletradecal.m . When i run it works fine. When i run through function(attached tcfun5.m) it is not running. I think local function withing the function is not running. Please help me fixing the problem.
Trade =[3 3 3 3 4 1 2 4]; %
Q = [ 46 46 46 46 46 46 46 46 ]; %Total Quantity
BP = [ 3500 3600 3700 3700 3800 3800 3700 3500]; % Buy Price
SP = [ 3508.1 4000 3800 3900 4000 3900 3900 3700]; % Sell price
Exch = [1 1 1 1 1 1 1 1];
[NETPL5, CHARGES5, SPOST5, STT5, TVS5, ETC5, IGST5, BROKERAGE5, SEBI5, STAMPDUTY5, DP5, MARGIN5, OCHARGES5, PAYINOUT5] = tcfun5(Q, BP, SP, Trade, Exch)
NETPL5 =
0
CHARGES5 =
0
SPOST5 =
0
STT5 =
0
TVS5 =
0
ETC5 =
0
IGST5 =
0
BROKERAGE5 =
0
SEBI5 =
0
STAMPDUTY5 =
0
DP5 =
0
MARGIN5 =
0
OCHARGES5 =
0
PAYINOUT5 =
0
  2 个评论
Walter Roberson
Walter Roberson 2022-7-26
It seems to be running. It returns all zeros though.
Triveni
Triveni 2022-7-26
It gives zero. But Actually, local function within the function is not running. when i run singletradecal.m it gives right values.
NETPL
NETPL =
62214.68
>> CHARGES
CHARGES =
-2557.92
>> SPOST
SPOST =
64450.36
>> STT
STT =
2146
>> TVS
TVS =
136.64
>> ETC
ETC =
94.19
>> IGST
IGST =
24.6
>> BROKERAGE
BROKERAGE =
40
>> SEBI
SEBI =
2.45
>> STAMPDUTY
STAMPDUTY =
161
>> DP
DP =
89.68
>> MARGIN
MARGIN =
64772.6000000001
>> OCHARGES
OCHARGES =
282.24
>> PAYINOUT
PAYINOUT =
64732.6000000001

请先登录,再进行评论。

采纳的回答

David Hill
David Hill 2022-7-26
Works. Just copy and paste singletradecal into your function or run the script inside the function.
function [NETPL, CHARGES, SPOST, STT, TVS, ETC, IGST, BROKERAGE, SEBI, STAMPDUTY, DP, MARGIN, OCHARGES, PAYINOUT] = tcfun5(Q, BP, SP, Trade)
singletradecal;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Transaction Cost Analysis 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by