I am trying to loop my if statement but I'm not sure how to

1 回表示 (過去 30 日間)
Belle Dionido
Belle Dionido 2022 年 4 月 21 日
回答済み: David Hill 2022 年 4 月 21 日
clc;
atomic_weight = [15.9994; 12.011; 14.00674; 32.066; 1.00794];
alanine = xlsread('lab12.xlsx','B4:F4');
arginine = xlsread('lab12.xlsx','B5:F5');
asparigine = xlsread('lab12.xlsx','B6:F6');
alaninemw = alanine*atomic_weight;
argininemw = arginine*atomic_weight;
aspariginemw = asparigine*atomic_weight;
file = input("Enter file name including file extension: \n",'s');
xlsx = 'xlsx';
while true
if contains(file, xlsx)
fprintf("The molecular weight of Alanine is %5f\n", alaninemw);
fprintf("The molecular weight of Arginine is %5f\n", argininemw);
fprintf("The molecular weight of Asparigine is %5f\n", aspariginemw);
else
false
end
end

採用された回答

David Hill
David Hill 2022 年 4 月 21 日
xlsx = 'xlsx';
while true
file = input("Enter file name including file extension: \n",'s');
if contains(file, xlsx)
fprintf("The molecular weight of Alanine is %5f\n", alaninemw);
fprintf("The molecular weight of Arginine is %5f\n", argininemw);
fprintf("The molecular weight of Asparigine is %5f\n", aspariginemw);
break;
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by