标签:plot figure Machine Octave y1 y2 Data sin axis
t=[0:0.01:0.98]; y1 = sin(2*pi*4*t); plot(t, y1)
If you draw tha cos function, it will replace the sin function figure to a new one
y2 = cos(2*pi*4*t); plot(t, y2)
So what if I want to draw cos and sin together in one plot?
hold on;
plot(t, y1)
plot(t, y2, 'r') # plot in red color
Add labels:
>> xlabel('time') >> ylabel('value')
>> legend('cos', 'sin')
>> title('my plot')
Save the plot:
print -dpng 'myPlot.png'
Close the plot:
close
Figure:
You can tell to generate different figures:
figure(1); plot(t, y1); figure(2); plot(t, y2);
Subplot:
subplot(1, 2, 1); # Divides plot a 1 * 2 grid, access first element
plot(t, y1)
subplot(1, 2, 2);
plot(t, y2, 'g')
axis:
Change the range of axis. axis([x0, x1, y0, y1])
axis([0.5 1 -1 1])
Clear the figure:
clf
iamgesc:
a = magic(5) imagesc(a), colorbar, colormap gray; # multi commands in one line
标签:plot,figure,Machine,Octave,y1,y2,Data,sin,axis 来源: https://www.cnblogs.com/Answer1215/p/13527055.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。