필터 지우기
필터 지우기

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