Hi,
Any ideas on the shortest way to perform a calculation on several different named variables to give output of different names too?
For example, say I have variables a1, a2, a3 and I want to produce output named f1, f2, f3 all of which are defined as
f1=10(a1)+6 f2=10(a2)+6 f3=10(a3)+6
what would be the shortest way to do this?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 20일
편집: Azzi Abdelmalek 2014년 2월 20일
The best way to do it is
a=[a1 a2 a3]
f=10*a+6
%instead of using many variables f1,f2 and f3, you have them in one
f(1)
f(2)
f(3)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2014년 2월 20일

댓글:

2014년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by