Info

此问题已关闭。 请重新打开它进行编辑或回答。

For else error and vector integration

1 次查看(过去 30 天)
Tomasz Mlynowski
Tomasz Mlynowski 2012-7-7
关闭: MATLAB Answer Bot 2021-8-20
I am trying to convert a (for if else) condition into a vector. I am having problems running the results after because I need to redefine the different Short and Long trades to be read as directionTrade i think. not sure what I am doing incorrectly.
I need to convert: -
if dist(k,i)>0
B_Short(k,i)=-1;
B_Long(k,p(i,1))=+1;
else
B_Short(k,p(i,1))=-1;
B_Long(k,i)=+1;
end
INTO......................
for i=1:length(idx)
if (dist(k,idx(i))>0)
myTrades{idxTrades,1}.directionTrade1=[-1 1];
else
myTrades{idxTrades,1}.directionTrade2=[ 1 -1];
Attempted added information Below. Not sure if correct...
directionTrade1=[B_Short(k,i) B_Long(k,p(i,1))];
directionTrade2=[B_Long(k,i) B_Short(k,p(i,1))];
This is where the problem arises.
% Calculation of the Total Buy_Signs Matrix
BsignsT(k,:)=B_Long(k,:)+B_Short(k,:);
Because it still reads B Long and B Short trades however I want to replace with the above vector else conditon. What do I need to change? and what do I need to change the name to for all recurrences of B Short and B Long in the remaining code for it to correctly read the newly changed vector and process the fucntion correctly..???

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by