希望在每个循环中都是能看到绘图,试了2种方法都不行
方法1:
plt.figure(1)
for w =1:3
t = collect(0:.1:10)
x = sin.(wt)
plt.plot(t,x,“ro”)
plt.hold(true)
println(w)
end
plt.show()
这种是显示所有循环运行之后的绘图,不是想要的
方法2:
plt.figure(1)
for w =1:3
t = collect(0:.1:10)
x = sin.(wt)
plt.plot(t,x,“r.”)
plt.hold(true)
println(w)
end
plt.show()
这种是每循环一次,显示一个绘图窗口,关闭窗口后再显示下一个,也不是想要的
在matlab中可以很容易实现:
clear;clc;close all
for i = 1:3
t = 0:0.1:10;
x = sin(i*t);
plot(t,x,‘ro’)
hold on
i
end
不知道这个话题适不适合在这里请教,如果违规请告知删除,谢谢