x = [-2:0.1:2];
z=x.*(a-x^2);
plot(x,z)
I want to plot(x, z) for four values of a = .5, 1, 1.3, 1.95. How to code it without writing same programme for different a four times.

 採用された回答

John Petersen
John Petersen 2012 年 12 月 18 日
編集済み: John Petersen 2012 年 12 月 18 日

6 投票

x = [-2:0.1:2];
a = [.5, 1, 1.3, 1.95];
figure;
for i=1:length(a)
z = x.*(a(i)-x.^2);
plot(x,z);hold on;
end

1 件のコメント

ABDUL RAZAK BIN NAINA MOHAMED
ABDUL RAZAK BIN NAINA MOHAMED 2019 年 9 月 29 日
how to give different color for each plot for this case

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by