[Machine Learning] Octave Plotting Data

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

 

posted @   Zhentiw  阅读(161)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-08-19 [Dart] final vs const
2015-08-19 [rxjs] Async, handle data over time
2015-08-19 [rxjs] Creating An Observable with RxJS
点击右上角即可分享
微信分享提示