Filter löschen
Filter löschen

Code not running when using &&

2 Ansichten (letzte 30 Tage)
sri satya ravi
sri satya ravi am 14 Jan. 2017
Bearbeitet: sri satya ravi am 14 Jan. 2017
Why is my code not running when using a && operator??
for i = 1:length (Power); if Power (i,1) >= 0.3*(max(Power)); Power_Boolean(i,1) = 1; else Power_Boolean(i,1) = 0; end end
for i = 1:length (RPM_Boolean); if (RPM_Boolean == 1) & (Torque_Boolean == 1) & (Power_Boolean == 1); Condition(i,1) = 1; else Condition (i,1) = 0; end end
I want to have the values where all three conditions are met

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Jan. 2017
Please read this http://www.mathworks.com/matlabcentral/answers/13205#answer_18099 so people can read your post.
Your code won't run if you use && with arrays. You have to use & to do an element-wide AND of corresponding elements. You're best off computing the result of the whole expression and saving it in one variable, then you'll typically want to put the resulting variable into any() or all() function.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by