How to solve this error "Operands to the || and && operators must be convertible to logical scalar values." ?
1 view (last 30 days)
Show older comments
I want matlab to display the new y values but i keep getting the error.
y = [5000 17000 25000 75000];
if y < 10000
ty = 200;
elseif y > 10000 && y < 20000
ty = (200 + 0.1*(y - 10000));
elseif y > 20000 && y < 50000
ty = (1200 + 0.15*(y - 20000));
elseif y > 50000
ty = (5700 + 0.25*(y - 50000));
end
0 Comments
Accepted Answer
KSSV
on 9 Apr 2020
Edited: KSSV
on 9 Apr 2020
Your input should be a scalar..i.e y should be a scalar.
y_val = [5000 17000 25000 75000];
ty = zeros(size(y_val)) ;
for i = 1:length(y_val)
y = y_val(i) ;
if y < 10000
ty(i) = 200;
elseif y > 10000 && y < 20000
ty(i) = (200 + 0.1*(y - 10000));
elseif y > 20000 && y < 50000
ty(i) = (1200 + 0.15*(y - 20000));
elseif y > 50000
ty(i) = (5700 + 0.25*(y - 50000));
end
end
3 Comments
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!