how to use "or"

2 次查看(过去 30 天)
Max Müller
Max Müller 2014-8-5
Can u pls tell me what is wrong ( just an example) How do i use the or command ?
for i = 1:100
if i == 2|5
disp('hallo')
end
end

采纳的回答

the cyclist
the cyclist 2014-8-5
for i = 1:100
if (i == 2)|(i == 5)
disp('hallo')
end
end

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2014-8-5
for ii = 1:100
if ii == 2 || ii == 5
ii
disp('hallo')
end
end
or
for ii = 1:100
if ismember(ii,[2,5])
disp('hallo'),ii
end
end

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by