Filter löschen
Filter löschen

Error : Operands to the || and && operators must be convertible to logical scalar values.

1 Ansicht (letzte 30 Tage)
Hi ,
I wrote this function:
function [flag_SO_Sell,flag_SO_Buy,flag_SO_Hold]= SO_Sub_Rule(Sthochestic_Osilator,High_SO,Low_SO)
% function [flag_SO_Sell,flag_SO_Buy]= SO_Sub_Rule(Sthochestic_Osilator,High_SO,Low_SO)
%%SO Rule
% Need to add for loop with index
% Sthochestic_Osilator([1:end],2)=Sthochestic_Osilator([]);
for i=1:length(Sthochestic_Osilator)
if Sthochestic_Osilator > High_SO
% 'Sell'
flag_SO_Sell=-1;
else if Sthochestic_Osilator < Low_SO
% 'Buy'
flag_SO_Buy=1;
else if (Sthochestic_Osilator > Low_SO) && (Sthochestic_Osilator < High_SO)
flag_SO_Hold=0 ;
% % disp ('Hold')
end
end
end
end
with any idea why i got this error from matlab in the command line: Operands to the and && operators must be convertible to logical scalar values.
Error in SO_Sub_Rule (line 13) else if (Sthochestic_Osilator > Low_SO) && (Sthochestic_Osilator < High_SO)
can someone tell what does this error mean?

Antworten (1)

Preethi
Preethi am 1 Dez. 2016
hi,
the output of < and > gives a vector since Sthochestic_Osilator is a vector. When using short circuit operators like '&&' the operators should be scalar. Using binary '&' in place of '&&' may help

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by