Anon
Anon

Reputation:

Maximum of two real numbers (scalars) on Matlab

I'd like a for loop to run whilst 'a' is the larger of 1 and 'b'. How do I make this happen? I guessed that 'for a = max(1,b)' would do it, but I ended up with a problem down the line that I think was caused by this.

Upvotes: 0

Views: 1660

Answers (2)

anon
anon

Reputation:

This should do it:

while (a > max(1,b))
end

Upvotes: 0

Sam Roberts
Sam Roberts

Reputation: 24127

You probably want while a==max(1,b). The for statement you have will run a single time, with a set to the maximum of 1 and b's value at the start of the loop.

Upvotes: 1

Related Questions