How do you do the following?

1. Let x take the values between −6π and 6π.
2. Use the for loop to calculate the sin(x). Store the results in y.
3. plot y vs. x.
4. Find the minimum point of sin(x) in this range of the values of x. Hint: use fminbnd. You may read about fminbnd by typing help fminbnd in the command window.

回答 (2 件)

madhan ravi
madhan ravi 2018 年 12 月 5 日

0 投票

1) Define x using increment.
2) Just use a for loop.
3)Use plot(...).
4)Use fminbnd(...) by parametrizing the function.
KSSV
KSSV 2018 年 12 月 5 日

0 投票

m = 100 ;
x = linspace(-6*pi,6*pi,m) ;
y = zeros(size(x)) ;
for i = 1:m
y(i) = sin(x(i)) ;
end
It is your job to do the rest. Read about min and fminbnd

カテゴリ

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

質問済み:

2018 年 12 月 5 日

回答済み:

2018 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by