Pairewise difference with bsxfun function and run all variables into it

hello,first of all i'm apologize for my easy question but i would like to know how can i calculate the bsxfun for all may variables that i have? for example i have: A1 A2 ... A15 that all are (31,1) and have some data. and i'm asking for bsxfun(@minus,A(i),A(i)') to store 31*31 B(i) pairewise difference.

답변 (1개)

James Tursa
James Tursa 2017년 2월 21일
편집: James Tursa 2017년 2월 21일

0 개 추천

How were these A1, A2, etc variables created in the first place? This is bad programming practice and leads to obfuscated code. The best thing for you to do is to first rewrite whatever code is producing those A1, A2, etc variables and get them into a single matrix or cell array to begin with. Then you can easily write code to do what you want to do with them. E.g., see this:
https://www.mathworks.com/matlabcentral/answers/105936-how-to-make-dynamic-variable-names-a1-a2-an-with-for-loop-using-eval-num2str

댓글 수: 1

in this approach i have problem that when i create variables in dynamic way using loop or etc. i must put all values manually to each variables. i'm sure for economic researching i must put probably more than 50 variables data. and for your question i import data from excel and rename all VarNames to Ai ones.

이 질문은 마감되었습니다.

질문:

2017년 2월 21일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by