필터 지우기
필터 지우기

Loop for function variable

조회 수: 2 (최근 30일)
Brian
Brian 2013년 5월 1일
Hello,
I need to set up a loop which will return the answers of a different function. What is the syntax to call the variables different names d1, d2, d3 from each iteration? I have tried the code in the loop A1, A2, A3 article, and other code. It doesn't seem to be relevant. The code is:
if i == 1;
xc = gd(2, i);
yc = gd(3, i);
r = gd(4, i)
% d1->..
% dx = dCircle(P,xc,yc,r) % x =1, 2,3 etc
It's proably something simple. Thanks for your time

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 5월 1일
I am going to refer you back to the article you mentioned because the simple answer to your question is: don't do it.
If you necessarily have to do it, then I will ask you to take a look at the EVAL function which can be used to do that.
Is there a reason you want to do that and not use the alternate approaches in the above link?
  댓글 수: 3
Shashank Prasanna
Shashank Prasanna 2013년 5월 2일
This should help:
>> i = 3;
>> eval(['x' num2str(i) '=5'])
>> x2 =
5
Brian
Brian 2013년 5월 2일
You legend! Thank you sir

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by