Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Moshe
Moshe le 1 Déc 2016
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?

Réponses (1)

Preethi
Preethi le 1 Déc 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

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by