Plot for different value of a

1 次查看(过去 30 天)
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
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

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by