Is it possible to make an if-statement with multiple conditions (a vector of numbers)?

4 次查看(过去 30 天)
Is it possible to make an if-statement with multiple conditions? I want the value of B(1, i) to change if it's any of the numbers 65 to 90. It does not work to simply type "if B(1, i)==65:90".
%Text that I want to decrypt
A=['VYDQBBO OEK CQDQWUT JE TUSHOFJ JXYI JUNJ!'];
B=double(A);
l=length(B);
x=(65:90);
%Loop to roll every letter 10 steps forward in the alpabet
for i=1:l
if (B(1, i)==x)
B(1, i)=(B(1, i)+10);
disp(B(1, i));
if (B(1, i)>90)
B(1, i)=B(1, i)-26;
end
end
end
A2=char(B);
disp(A2);

采纳的回答

Stephen23
Stephen23 2018-12-14
编辑:Stephen23 2018-12-14
Use any:
if any(B(1,i)==65:90)
if ismember(B(1,i),65:90)

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by