필터 지우기
필터 지우기

For ... Next Loops

조회 수: 3 (최근 30일)
Paul Mitchell
Paul Mitchell 2020년 12월 15일
댓글: Paul Mitchell 2020년 12월 19일
The problem
I would like to use xlsread to define inputs to a function - I have many combinations of inputs to contend
with (5000) and feel it would be easier to control via the use of an Excel Spreadsheet (rather than hard
coding in matlab)
However some of the inputs my be defined as say a = single doubles, b = loop from min:step:max, and
and c = series [low mid high] or even textual array. These would have to then form nested loops to step
over all combinations. Is there a method i can use within matlab m file to control how to configure to loops
I could loop round all the inputs in the xls sheet (accessed via xlsread) doing a checks to determine
which format the input may take and hence forming a nested loop
for loop1=a
for loop2=b
for loop3=c
DoFunc = func(loop1, loop2, loop3)
end
end
end
but given I may have 50 variables I do not really want 50 nested loops
Any suggestions of a elegant method (or alternatives) I could employ
Thank You
  댓글 수: 3
Paul Mitchell
Paul Mitchell 2020년 12월 19일
Stephen, thank you for the links, I think the allcomb function referenced on the final link is something I can use, its just a matter of sorting out how to get Matlab to handle inputs on the Excel worksheet which could be defined as either
Single values i.e. A = 5000;
Or a defined set of values A = [5000 10000 15000];
Or a range of values such A = 5000:5000:15000;
The singles I would not want to occupy the allcomb fields, but either of the other two options I would
I'll keep playing with my script to see if I can comeup with an elegant solution
Regards, Paul

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by