フィルターのクリア

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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by