how can i call up either part of the results like (e1,e5,e6,e9)or (from e1 to e7)? then i need to combin them in one array

2 次查看(过去 30 天)
if i have a lot of arrays with different dimensions and their names take the following forms :e1,e2,e3,...,e10 and so on. how can i call up either part of the results like (e1,e5,e6,e9)or (from e1 to e7)? then i need to combine them in one array . for your information , these array names resulted from this code :
a=[1:10];
c=length(a)
for k=1:10;
if (k<c)
b{k}=nchoosek(a,k)
end
end

回答(1 个)

Roberto
Roberto 2014-6-21
I'm assuming that the results e1, e2, e3... in the code you wrote is b{k}... you might get your results as an numeric array or as a cell array
Array form: Results 1 to 4
myArray = [b{1:4}]
Cell form: Results 7 to 2
myCell = b{7:-1:2}
Array form: Results 4 to last
myArray = [b{4:end}]
Cell form: Results 3, 6 and 2
myCell = b{[3,6,2]}
Array form: Every other result
myArray = [b{1:2:end}]

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by