Store all user inputs from a loop + how to make the loop non-repeated

1 回表示 (過去 30 日間)
Yuexiaoxi Yu
Yuexiaoxi Yu 2019 年 6 月 22 日
コメント済み: Yuexiaoxi Yu 2019 年 6 月 22 日
Please help me, I'm super new to matlab and trying to figure everything out. I'm trying to randomly generate a word from a excel list and get a user input for each of them. Then I want all the inputs recorded in a cvs. file along with the generated words.
ALso I found that the words repeat within the loop and I want a unique word each time but have no idea how to do it.
for k = 1:10
english=importdata('testing.xlsx');
a=english(randi(numel(english)));
disp(a);
b=(input('Enter:','s'));
% it only recorded the last input. How do I fix this?
end

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 22 日
english = importdata('testing.xlsx');
Ntry = 10;
b = cell(Ntry, 1);
word_order = randperm(numel(english), Ntry);
for k = 1:ntry
a = english{word_order(k)};
disp(a);
b{k} = input('Enter:','s');
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by