a problem with for loop and indexinf

1 回表示 (過去 30 日間)
Rica
Rica 2014 年 5 月 20 日
編集済み: Andrei Bobrov 2014 年 5 月 20 日
Hi all!
i have 10 Arrays. they have the Name Array_1..........Array_10. for all of the Arrays i want to make some mathematical Operation e.g:
%AR_1=exp(Array_1)+Array_1.^2;
how could i do this with a for Loop like this:
% for k=1:10
AR_i=exp(Array_i)+Array_i.^2
end
Thank you all

回答 (2 件)

George Papazafeiropoulos
George Papazafeiropoulos 2014 年 5 月 20 日
編集済み: Andrei Bobrov 2014 年 5 月 20 日
A={Array_1;Array_2;Array_3;Array_4;Array_5;Array_6;Array_7;Array_8;Array_9;Array_10};
for k=1:10
AR{k}=exp(A{k})+A{k}.^2
end

Andrei Bobrov
Andrei Bobrov 2014 年 5 月 20 日
A = eval(strcat('{',sprintf('Array_%d;',1:10),'}'));
AR = cellfun(@(x)exp(x)+x.^2,A,'un',0);

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by