Machine Learning 5 Basic Operations

Machine Learning 5 Basic Operations

5-4 Plotting data

  • T = [0:0.1:1]
  • Y1 = sin(2*pi*4*t)
  • Plot(t,y1) //绘图程序
  • Hold on 在原图基础上绘制
  • Xlabel(‘time’)
  • Ylabel(‘value’)
  • Legend(‘sin’,’cos’) 为线进行标注
  • Title(‘my plot’) 标题
  • Print -dpng ‘myplot.png’ 保存
  • Close 关闭图像
  • Figure(1); plot(t,y1);
  • Figute(2);plot(t,y2);
  • Subplot(1,2,1); %Divides plot a 1x2 grid
  • Axis([0.5 1 -1 1])
  • Clf 干掉所有的图片
  • Imagesc(A) 可视化矩阵
  • Imagesc(A), colorbar, colormap gray; 为图片添加bar,设置颜色为灰色

5-5 Control Statements for, while, if statements

语法上不对缩进有要求

  • for
for i = 1:10,
    v(i) =  2^i;
    end;
indices = 1:10;
for i = indices.
    disp(i);
end;
  • while
while i <= 5,
    v(i) = 100;
    i = i+1;
end;
  • break
while true,
    v(i) = 999;
    i = i + 1;
    if(i == 6),
        break;
    end;
end;
  • if else
if v(1) == 1,
    disp('The value is one');
    elseif v(1) == 2,
        disp('The value is two');
    else
        disp('end');
end;
  • exit/quit 退出octave
  • function 使用时,要把函数放在当前空间
function y = squareThisNumber(x)
y = x^2;
function [y1, y2] = squareAndCubeThisNumber(x); % 返回多个值
y1 = x^2;
y2 = x^3;
function J = costFunctionJ(X, y, theta)
% X is the "design matrix" containing our training examples.
% y i the class labels
m = size(X, 1); % number of training examples
predictions = X*theta; % predictions of hypothesis on all m examples
sqrErrors = (predictions - y).^2; % squared errors

J = 1/(2*m) * sum(sqrErrors);
  • addpath 添加搜索路径
addpath('C:\users\ang\Desktop')

Vectorization

  • 向量化可以降低计算时间,提升编程效率

Working on and submitting programming exercises

cd '作业所在目录'
submit()
### Raspberry Pi 5 Camera Usage Tutorial For utilizing the camera module with a Raspberry Pi 5, one needs to ensure that both hardware connections and software configurations are correctly set up. Although specific tutorials directly targeting Raspberry Pi 5 might not yet be abundant due to its recent release, instructions for previous models like Raspberry Pi 4 largely apply here. #### Hardware Setup Ensure the camera module is properly connected to the CSI port on the Raspberry Pi board. The ribbon cable of the camera should gently slide into place without forcing it; make sure the silver contacts face towards the HDMI ports[^1]. #### Software Configuration After connecting the camera physically, configuration through `raspi-config` becomes necessary. Open terminal access: ```bash sudo raspi-config ``` Navigate within this tool until reaching "Interfacing Options", then select "Camera". Choose "Yes" when asked whether to enable the camera interface. Once completed, rebooting may sometimes become required for changes to take effect. #### Testing the Camera Module With everything configured appropriately, testing can commence via command line tools such as raspistill which captures still images or raspivid responsible for video recording operations. Capturing an Image Example: ```bash raspistill -o testimage.jpg ``` Recording Video Example (lasting five seconds): ```bash raspivid -t 5000 -o testvideo.h264 ``` These commands provide basic functionality tests ensuring proper operation after setup completion. #### Advanced Features Using Python and OpenCV Beyond simple capture capabilities, integrating advanced features requires leveraging libraries including OpenCV mentioned earlier. Through Python scripts combined with OpenCV functions, developers gain powerful means to process captured media further enhancing project functionalities beyond mere data acquisition. --related questions-- 1. How does one configure additional settings for better image quality? 2. What alternatives exist if facing issues during installation processes related to camera support? 3. Can machine learning methods integrate seamlessly with live feed processing from the camera using OpenCV? 4. Are there any particular considerations while choosing between different versions of camera modules compatible with Raspberry Pi 5?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值