Creating new variables and matrix manipulation

Hi,
From:
A = 9
[55;61;66;68]
20
60
[47;83;105]
72
[44;57];
B = [1;2;5;6;8;9;10];
I am trying to create matrices with names that look like:-
A1 = [9];
A2 = [55;61;66;68];
A5 = 20
A6 = 60
A8 = [47;83;105]
A9 = 72
A10 = [44;57];
Any help will be fanatastic. Thanks

 採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 9 月 9 日

0 投票

Do not do it.
Read the FAQ
only for theory!!!
inital:
A = {9
[55;61;66;68]
20
60
[47;83;105]
72
[44;57]};
B = [1;2;5;6;8;9;10];
soltion
for i1 = numel(B):-1:1
eval(['A',num2str(B(i1)),'=A{',num2str(i1),'}']);
end

3 件のコメント

Amandeep
Amandeep 2011 年 9 月 9 日
Just wondering why this doesn't work?
for k = 1:size(A,1)
A{B(k,1)} = A{k};
end
Andrei Bobrov
Andrei Bobrov 2011 年 9 月 9 日
Index exceeds matrix dimensions in B
Amandeep
Amandeep 2011 年 9 月 9 日
Thanks for the reply

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by