Greater than operator not working in if statement

14 views (last 30 days)
Here is my code, POLY60estra is a 1000x1 vector. here is the lines of code
for p=1:500
if (POLY60estra(p,1) > 0) && (POLY60estra(p,1) <= 7.1)
POLY60estra2(p,1) = POLYestra(p,1);
POLY60estre2(p,1) = POLYestre(p,1);
end
end
Thank you for any help ahead of time.
  3 Comments
Jacob Huhtala
Jacob Huhtala on 23 Sep 2020
The code crashes when its ran, giving me the error code,
"Undefined operator '>' for input arguments of type 'table'.
Error in StressStrainLab (line 88)
if (POLY60estra(p,1) > 0) && (POLY60estra(p,1) <= 7.1)"

Sign in to comment.

Answers (1)

David Hill
David Hill on 23 Sep 2020
Edited: David Hill on 23 Sep 2020
No need for loop.
idx=(POLY60estra(1:500)>0&POLY60estra(1:500)<=7.1);
POLY60estra2(idx)=POLYestra(idx);
POLY60estre2(idx)=POLYestre(idx);
  3 Comments
Jacob Huhtala
Jacob Huhtala on 23 Sep 2020
That actually got it to work properly. Thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!