Show older comments
現在for文を用いてa=1のもとbを1から100まで1づつ増やして最小にしたい関数C(a,b)が最小になるbを求めるプログラムを以下のように書いています。
a = 1
b = -10:1:10
C1= zeros(1,length(b))
for i=1:length(b)
C(i) = a*cos(b(i))+5*sin(b(i))
end
[A,B]=min(C)
これによって関数Cの最小値AとB(最小になるときのb)を求めています。
この処理をa=1から100まで繰り返し,aとBのグラフを書きたいのですがfor文の使い方がよくわからずできません。参考になるページ等あれば教えてください。
Accepted Answer
More Answers (0)
Categories
Find more on ループと条件付きステートメント in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!