Afficher commentaires plus anciens
現在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文の使い方がよくわからずできません。参考になるページ等あれば教えてください。
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur ループと条件付きステートメント dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!