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? Thanks

4 件のコメント
Kevin Phung
2019 年 3 月 28 日
what have you tried so far?
Malath Al-Khairi
2019 年 3 月 28 日
Kevin Phung
2019 年 3 月 28 日
instead of defining conditions for y, you should check conditions for x and evaluate y
Walter Roberson
2019 年 3 月 28 日
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
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
