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 Kommentare

Kevin Phung
Kevin Phung am 28 Mär. 2019
what have you tried so far?
Malath Al-Khairi
Malath Al-Khairi am 28 Mär. 2019
Screen Shot 2019-03-29 at 10.04.45 AM.png
Kevin Phung
Kevin Phung am 28 Mär. 2019
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Mär. 2019

Kommentiert:

am 28 Mär. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by