フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Transforming Result to Meaningful Information

2 ビュー (過去 30 日間)
RDG
RDG 2011 年 12 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Suppose I have a cell array as such:-
a=cell(5,1);
for i=1:5
a{i}=i
end
I have an excel file with 2 columns which describe the following:-
1 John
2 Peter
3 Terry
4 Alice
5 Mary
Is there a way to point the cell array result to the following information instead of displaying integer as the final result?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 12 月 8 日
You probably mean indexing. For example
Names={'John', 'Peter','Terry','Alice','Mary'};
ind=[3 1 4 2];
SelectedNames=Names(ind)
It's better to use double array (like the variable 'ind' in the above code) than cell array for your 'a' variable if it contains scalar numerical value in every cell. If you have to use cell array, you can use
a=num2cell(1:5)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by