2

I have a for loop in Matlab; inside it I am calling a function which uses a matrix as an input. Here is how it looks:

for S=1:10
...
functionA(optimumS1)
...
end

I loaded optimumS1, optimumS2... matrices. How can I use different matrices each time?

2
  • What do you mean by "each time"? Do you mean in every iteration? If S=1 use optimumS1, if S=2 use optimumS2 and so on...? Commented Jan 17, 2012 at 16:33
  • @Niclas Yes Niclas.I was trying do this:filename = ['OptimumS' num2str(S)]; But I need to convert char to variable since file name is a char Commented Jan 17, 2012 at 17:39

1 Answer 1

6

Try using a cell array:

optimum = {optimumS1, optimumS2, ..., optimumS10 };
for S=1:length(optimum)
    ...
    functionA(optimum{S});
    ...
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.