In "if "stetment, I got a problem to write the range of the variable

if A > 0 && A <= 5;
AT=65.1+rand*(93.8-65.1);
end
I got the following error message:
Operands to the || and && operators must be convertible to logical scalar values.
Error in PVSAT2 (line 130)
if A > 0 && A <= 5;

Answers (1)

Your "A" is a vector or matrix. Do you want the condition to apply if all A are in that range, or if any A is in that range? Or are you thinking that there is one AT per A value and you only want to change the AT value that correspond to the values of A that are in that range ?

This question is closed.

Tags

Asked:

on 30 Apr 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!