While loops, please help

Give the following function
f(x)= x^3 -(5x)^2 +2^(x) - 10000x
Use a while loop to compute f(x) and then create a plot for 0<x<20.
This is what I have so far, I know I have to define x but I don't know what to set x= to since it did not specify.
f(x)=x^3 -(5*x)^2 +2^(x) -10000*x;
while 0<x<20
end

回答 (2 件)

Roger Stafford
Roger Stafford 2014 年 9 月 19 日

1 投票

Here's something to get you started:
x = linspace(0,20,500);
will create a vector of 500 values of x uniformly spaced between 0 and 20. Now see what you can do with that vector towards getting something to plot.

1 件のコメント

suraj giri
suraj giri 2017 年 2 月 27 日
sir, it is asked to plot (0<x<20), that means x has have value greater than 0 and less than 20, but according to your command, x=linspace(0,20,500), x will have 500 values between 0-20 including 0 and 20 but we must not have 0 and 20 :)

サインインしてコメントする。

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 9 月 19 日

0 投票

there are examples in this help

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2014 年 9 月 19 日

コメント済み:

2017 年 2 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by