How do I use the for loop function?

I need help with this question please. How do I go about writing it out in Matlab? ThanksScreen Shot 2019-03-29 at 9.42.19 AM.png

4 Comments

what have you tried so far?
instead of defining conditions for y, you should check conditions for x and evaluate y
You do not define y.
If you did define y, then you would have the problem that ((x.^2)./((x.^2)+1)) is a vector, and you would be comparing y to a vector. You would get a vector of logical results. When you have an vector or array of logical values in an if statement or while loop, then the condition is considered true only if all of the values are non-zero (that is, true) just as if all() had been written,
if all(y==((x.^2)./((x.^2)+1)))
If even one of those results was not true then the entire test would be considered false. It is possible that none of your three tests would be considered true, since each one of them might have some element where the test was false.
You also have the problem that you are comparing for bit-for-bit equality when you use == . If there was even a single bit difference due to round-off error, then you would get the result false. For example, due to round-off, 1/49 * 49 is not exactly 1.0

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 28 Mar 2019

Commented:

on 28 Mar 2019

Community Treasure Hunt

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

Start Hunting!