0

I am trying to figure out how to create a loop in matlab that can repeat a statement but increase/decrease the numbers in the statement each time.

So, for example, I want to repeat the statement -

Elset, elset="element 1", instance="simple plate-1" 150000,

Many times over so but increasing the element numbers so that it starts to come together like this -

Elset, elset="element 1", instance="simple plate-1" 150000,
Elset, elset="element 2", instance="simple plate-1" 149999,
Elset, elset="element 3", instance="simple plate-1" 149998,
Elset, elset="element 4", instance="simple plate-1" 149997,
Elset, elset="element 5", instance="simple plate-1" 149996,
Elset, elset="element 6", instance="simple plate-1"

This feel as though it should be very simple but I havent figured it out yet. Please help!

1 Answer 1

1

Something like this:

lineStr = 'Elset, elset="element %d", instance="simple plate-1" %d,\n'

for i = 0 : 150000 - 1
    fprintf(1, lineStr, i, 150000 - i);
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.